checking file existance

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • borec
    New Member
    • Jun 2007
    • 2

    checking file existance

    how do I check if a file with a specific name exists in a folder on my computer. Im working on a macro in MSWord. Please help.

    Some suggested:

    [CODE=vb]If System.IO.File. Exists(fileToOp en) = True Then
    ...

    Else

    ...

    EndIf[/CODE]
  • borec
    New Member
    • Jun 2007
    • 2

    #2
    I found

    Object.FileExis t(FileToOpen) but I can't get it work. Debbuger alerts error.

    Comment

    • Killer42
      Recognized Expert Expert
      • Oct 2006
      • 8429

      #3
      Originally posted by borec
      Some suggested:[CODE=vb]If System.IO.File. Exists(fileToOp en) = True Then
      ...
      Else
      ...
      EndIf[/CODE]
      Well, does it work?

      As for your other post, please give us the specific details of the reported error.

      Also, I don't know whether it matters (not really my area of expertise) but what version of Word is this?

      Comment

      • Killer42
        Recognized Expert Expert
        • Oct 2006
        • 8429

        #4
        Just a quick note - the Dir() function is useful for checking whether files exist.

        For example...[CODE=vb]If Dir(fileToOpen) = "" Then
        ' File doesn't exist
        End If[/CODE]Check the doco for parameters.

        Comment

        Working...