How to get name of file

In a folder I have a file called "file1.grf"
There may also be a file called "file1_zx.grf"
I dont know the exact name - only that it will be like "file1_*.grf"
I have the path of the folder, and I know the name "file1.frg".
How do I get the name of the file "file1_zx.grf" if it exists?
I would like to have a function like
Public Function fileName(name as string, path As string) As string
that returns the proper name or blank if it does not exist.
I have rutines like - and I hope to make something similar:
Public Function file_exists(path As Variant) As Boolean
    Dim FS As Object
    file_exists = False
    Set FS = CreateObject("scripting.filesystemobject")
    If Not IsNull(path) Then
        If FS.FileExists(path) Then
            file_exists = True
        End If
    End If
End Function
Public Function folder_exists(path As Variant) As Boolean
    Dim FS As Object
    folder_exists = False
    Set FS = CreateObject("scripting.filesystemobject")
    If Not IsNull(path) Then
        If FS.folderexists(path) Then
            folder_exists = True
        End If
    End If
End Function

Hi,
<< How do I get the name of the file "file1_zx.grf" if it exists?
Before you get the name the file, first you need to be sure the file existed, then get the file name from the path. Here are ways you can refer to
' judge the file exists or not
Function IsFileExists(ByVal strFileName As String) As Boolean
If Dir(strFileName, 16) <> Empty Then
    IsFileExists = True
Else
    IsFileExists = False
End If
End Function
' judge the file exists or not
Function IsFileExists(ByVal strFileName As String) As Boolean 
Dim objFileSystem As Object 
Set objFileSystem = CreateObject("Scripting.FileSystemObject") 
If objFileSystem.fileExists(strFileName) = True Then 
IsFileExists = True 
Else 
IsFileExists = False 
End If 
End Function
' Get the file name
Function GetFilenameFromPath(ByVal strPath As String) As String
' Returns the rightmost characters of a string upto but not including the rightmost '\'
    If Right$(strPath, 1) <> "\" And Len(strPath) > 0 Then
        GetFilenameFromPath = GetFilenameFromPath(Left$(strPath, Len(strPath) - 1)) + Right$(strPath, 1)
    End If
End Function
Sub Run()
   If IsFileExists("D:\vba\abc.txt") = True Then
   FileName = GetFilenameFromPath("D:\vba\abc.txt")
    MsgBox (FileName)
Else
       MsgBox "No releevant file"
    End If
End Sub
Hope this could help you.
Best Regards
Lan
We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
Click
HERE to participate the survey.

Similar Messages

  • How to get list of file names from a directory?

    How to get list of file names from a directory?
    Please help

    In addition, this:
    String filename = files;Should be this:
    String filename = files;
    That's just because he didn't use the "code" tags, so [ i ] made everything following it become italicized.                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • How to get names of method parameters ?

    How to get names of method parameters (Not only their type and value) is it only possible during debugging ??
    for example void myFunction(int a,int b)
    I need the "a" , and the "b" The issiue is about the java.lang.reflect.InvocationHandler ,
    and its method invoke(Object proxy,
    Method method,
    Object[] args)
    throws Throwable
    I Have the parameter objects themself and their types using method.getParameters() , this is fine ,, but i need the names of the parameters !!!

    If the class file was compiled without debug information included then it is impossible to get the original parameter names, as used in the source code.
    However, If the class file does include debug information, then the method names are hidden deep within the class file. You'd need to parse the class file yourself. Check out a copy of the Java VM Specification for a detailed format of the java class file format.
    It's not a trivial task to parse the java class file, and the VM spec isn't easy reading. You'd nearly be writing a class file disassembler.

  • I imported different trips to different catalogs on different external hard drives.  Later renamed external HDs.  I want to combine catalogs and have my source (NEF) files all together on one drive.  I'm not really sure how to get those source files back

    I imported different trips to different catalogs on different external hard drives.  Later renamed external HDs.  I want to combine catalogs and have my source (NEF) files all together on one drive.  I’m not really sure how to get those source files back and get rid of the extra long path to where the source files are now located. If I re-link files to their current catalog (many different paths to files in same catalog) can I merge (import catalogs) into one master catalog?  Will the new (Master catalog) have the correct link to the source file?  If not, how or can this be done?
    I have tried to explain my situation as clearly as I can.  Do you understand my situation?
    This maybe something you don’t have time to help me with.  If not can you suggest somewhere I can get an answer?  I really need help.  PLEEEZZZ HELP ME.
    Bruce Schuerman
    Norman, OK
    405_514-4875 (call collect)
    [email protected]

    Is there any solution (other than buying
    I really think 'buying' is the best solution on this one.  Ideally, you would have at least five internal hard drives.
    System
    Projects
    Cache/Scratch
    Media
    Exports
    Use externals and network drive only for backup.

  • How to get a PDF file in iMovie ?

    Hello,
    I have a sketch as a PDF file on my desktop.
    How can I get this sketch in iMovie '11 ?
    Thanks for your answer !
    John

    Thank you, but I have to be more clear ...
    I received a drawing from a friend - a Windows user - as a "docx" file.
    When I clicked on it, it opened in Pages '09 version 4.0.5 with a message popped up stating : - Some warnings occurred. Would you like to review them now ? You can review warnings at any time by choosing View > Show Document Warnings.
    With "Don't Review" or "Review" commands.
    I clicked on "Review" and saw a Documents Warning stating a Missing font Calibri.
    Clicking on Share > Create a PDF document that can be viewed and edited with a PDF application, or viewed in a web browser. Image quality 'Good' . And command 'Next …' and saved as ' logos1.pdf ' on Desktop command EXPORT.
    It opened in Adobe Reader and I saw this message :
    - This document does not allow you to save any changes you have made to it unless you are using Adobe Acrobat 9, Adobe Acrobat Pro 9, or Adobe Acrobat Pro Extended 9. You will only be saving a copy of the original document. Do you want to continue? -
    The Adobe Reader vs 9.4.2 was put on my Mac years ago …
    I have the feeling I'm circling around a problem while NOT knowing how to get the sketch file in iMovie '11 …..
    Please tell me what do I do wrong ?
    Or should I ask my friend to resend the logo in another, and what file format ?
    Hope I could make myself understandable, after several years living as a dutchman in France ?

  • How to get name of sbRIO programatically

    How to get "name" and "Comment" of sbRIO which I write to sbRIO-9602 in MAX in Identification box (Model, Serial number, MAC address, Name)?
    Solved!
    Go to Solution.

    That shows:
     - IP settings
          - IP adress:        136...etc.
          - DNS name:      MyMaster5                   - THAT IS WHAT I NEED, just in wrong place - in MAX it is not in IP settings, that's why i didn't searched for it there.
          - subnet mask    255.255.255.0
          - gateway          136...
          - DNS server      136...
     - MAC address        00800...
     - serial number        16....
     - system state        Running
     - model name         sbRIO-9602
     - model code          7373
     - password protected restarts?    T/F
     - halt if TCP/IP fails?                   T/F
     - locked?                                   T/F
     - use DHCP?                             T/F
    Still there is no "comment" as in MAX. But that's not so important now.
    I have LW Development system 2009 SP1 Profesional, Realtime Development 2009 SP1
    Thanks very much!

  • How to get name of table from front end

    Hi,
    How to get name of table from front end in EBS 11i?
    thanx
    Ashish

    Hi
    Sandeep is correct. The "Help"/"Record History" will give you the table/view name, but sometimes this particular menu function give me a "Record History is not available here." error message.
    I then use the following menu functions (this will also give you additional information, like column details).
    1) Open Forms
    2) Click on Help/Diagnostics/Examine (*you might have to enter the APPS password at this point)
    3) Change "Block" to "System"
    4) Change "Field" to "Last_query"
    The system will populate the "Value" field with the query that was executed in order to populate the form.
    Regards
    Frank

  • How to get the ard file of crystal reports

    Hi all,
    I have downloaded crystal reports from sap market place but i dont have .ard file for that how to transfer that reports into sap. How to get the ard file please help me out.
    Thanks & Regards,
    Murtuza Ahmed.

    When you click on your SAPCrystalSetup.exe and select the path to your add-on folder it will install the files and your ard file will be situated in your add-on folder.  Then you can start SAP up and install it from SAP. 
    So if your SAP install is in your local drive your ard file for crystal reports should be here C:\Program Files\SAP\SAP Business One\AddOns\SAP_CR
    Hope this helps.

  • How to get back hosts file

    help me pls..
    my iphone can't be update bcos file hosts deleted. i use mac OSX 10.6.8..
    how to get back the file hosts?...thank...

    ''Nokios [[#question-1058774|said]]''
    <blockquote>
    Woke up to find that , the file I left downloading through the night was not here afters hours of downloading time and bandwidth .
    I discovered a very disturbing unacceptable "Blocked may contain a virus or spyware"..MAY !!!
    I am mad against Mozilla because I do not have the time to re download. Here is my question:
    Is there a "Vault" or a "quarantine" folder where I can recover this file??
    (I know that the source of such messages is Google and that in the future I will uncheck a line on the options' security tab.This is not my problem.)
    My problem is: Can I find it somewhere and recover it without re-downloading??
    </blockquote>
    Unfortunately the file is not stored anywhere on your harddrive. It has been deleted entirely.
    If you think this file block is a "false positive" and that the file is actually safe, you could do one of the following:
    (1) Download the file using a downloader add-on that bypasses this security check. I heard about this in another thread but haven't tried it myself (and also, I don't know which add-ons to trust for this!).
    (2) Disable the Safe Browsing feature temporarily to get the file, then turn it back on. There is a checkbox in the Options dialog:
    "3-bar" menu button (or Tools menu) > Options > Advanced
    On the Security tab, it's the "Block reported attack sites" checkbox. The other checkbox relates to phishing sites and I don't think it affects downloads.

  • How to get the wsdl file

    hi all,
    here java people have given wsdl file to me, how to do the scenario,
    and how to get the wsdl file from the java people.
    regards,
    priya

    Hello Priya,
    Go to http://<hostname>:50000/wsnavigator or any other UDDI server and search for the web service to be invoked
    There you can find the Webservice Definition (WSDL) file.
    Check this weblog:
    Invoke Webservices using SAPXI
    regards
    Gangaprasad

  • How to get Jxl.jar file

    Hi,
    Can any one tell me how to get Jxl.jar file.
    Thanks & Regards,
    Laxmi

    Hi,
    [jxl.jar|http://www.java2s.com/Code/JarDownload/jxl.jar.zip]
    or else
    open google, and serach for download jxl.jar
    Regards,
    Srinivas

  • VISA: How to get the CSV file through C/C++ code?

    How to get the CSV file through C/C++ code?
    I'm communicating with a USB oscilloscope using VISA.

    Thank you for your reply.
    I am using Apache Commons File Upload. Here is the code where I got the "fi".
         DiskFileUpload fu = new DiskFileUpload();
              fu.setSizeMax(1000000000);
              List fileItems = fu.parseRequest(request);
             Iterator itr = fileItems.iterator();
              FileItem fi = (FileItem)itr.next();
              if(!fi.isFormField())
                File tempFileRef  = new File(fi.getName());
         System.out.println("Field = "+tempFileRef.getAbsolutePath());
         }

  • How to get Reference on files of my ADF Shared Library

    Dear All,
    Use case:
    I have compiled one project into a shared ADF library. This project has a ViewController.
    In it are some common css files that I would like to reuse.
    Now, I have a new project and have linked to that ADF library using Resource Palette.
    In my JSFF file, I tried to link to the CSS in my shared library
    <af:resource type="css" source="/com/test/common.css"/>But I cant seem to get the styleclasses in that shared library.
    I have checked at Firebug console and I notice that I am getting a 404 when I am requesting for the said file.
    What should be the correct path for me to get a reference to the CSS Files?
    Thanks
    JDEV 11G PS3

    Duplicate of How to get Reference on files of my ADF Shared Library
    Edited by: Bijesh Krishnadas on Aug 17, 2011 9:13 PM

  • Does anyone know how to get a preflight file signed by apple for the 21 mac

    does anyone know how to get a preflight file signed by apple for the 21 mac

    im trying to get a hold of them to see if they can deauthorize a computer. I am unable to do it because i can't get the internet to hook up. And i got a new laptop that i get the internet on but i can't authorize it unless i deauthorize the other one. i've called apple 3 times and theyve not been very helpful saying i need to get  hold of itunes.

  • How to get names of sub tabs?

    Hi All,
    Could someone tell me how to get names of all sub tabs?
    I have Parent Tab T1. T1 has 3 sub tabs T1_1, T1_2 and T1_3.
    I would like to have T1_1, T1_2 and T1_3 sub tab names in the list.
    Thanks in advance!!
    Dip

    Dip,
    You can get the tab names from apex dictionary views, apex_application_tabs & apex_application_parent_tabs . Thanks.
    Regards,
    Manish

Maybe you are looking for

  • PO print out of delivery schedule

    Hi, Suppose I am generating a PO , in some cases I will be giving delivery schedule for some items in item details. I want this to come in the print out. But its not coming . Please advise. regards,

  • Long running mapping execution...?

    I have a mapping that selects from a 40+ milion row table over a database link but with the FILTER Operator I'm using it should only bring back about 20,000 rows. The mapping has been executing for over 2 hours :-( In checking the remote system, ther

  • All iPOD music gone

    Ok, now I am furious... after doing the updater and such, iTunes for some reason updated all my songs from Library to my iPOD, I saw it... took some time... now looking at my iPOD, there is nothing there! Gone! Dont know why it wiped out my music but

  • Problem with RSCRM_BAPI (extraction to Fixed Lenght txt file)

    Hi Experts, I have a question about a RSCRM_BAPI limitation: I want to extract a Query, using this transaction, to a fixed lenght .txt file. The query has a tabular structure like this: CHARACT1 | CHARACT2 | CHARACT3 | CHARACT4 | KEYFIG_MONTH1 | KEYF

  • How to stop the program for a while?

    Hi, I've created a small prog that the only thing it does is to ask for a given password before granting access to certain data. It works fine on the WTK emulator (from Sun of course), but it crashes on a Nokia 6600 due to a bug in the Nokia's MIDP2.