Results 1 to 4 of 4

Thread: checking to see if a file exists in Word... RESOLVED!

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    2

    Resolved checking to see if a file exists in Word... RESOLVED!

    hi --

    I'm attempting to write a script in Word in which the script checks a specific folder for a specifically named file. If it's not there, it then looks for the next file.

    Not sure what to do here - any advice much appreciated. Thanks!
    Last edited by apeface76; Jul 20th, 2005 at 08:29 AM.

  2. #2
    Fanatic Member
    Join Date
    Sep 2002
    Location
    Lexington, SC
    Posts
    586

    Re: checking to see if a file exists in Word... help!

    The easiest way I find to check for files existing without the old error trapping way is a file system object.

    VB Code:
    1. Set FSO = CreateObject("Scripting.FileSystemObject")
    2.  
    3. If FSO.FileExists(FileName) Then
    4.    'Conditions if true
    5. Else
    6.    'Not true
    7. End If

    If someone could I'm not totally sure about the createobject, can't remember if its Scripting. or something else... usually just reference it in VB but know you can do it this way to because I had to do it once on an asp page.

  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2005
    Posts
    2

    Resolved Re: checking to see if a file exists in Word... RESOLVED!

    fantastic. thanks for the help!

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: checking to see if a file exists in Word... RESOLVED!

    Another option is the PathFileExists API.

    VB Code:
    1. Declare Function PathFileExists Lib "shlwapi.dll" Alias "PathFileExistsA" (ByVal pszPath As String) As Long


    Has someone helped you? Then you can Rate their helpful post.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width