Thanks Thanks:  0
Likes Likes:  0
Results 1 to 3 of 3

Thread: open file in macro fails

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Posts
    91
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    I am trying to open a file in macro and if does not exists i am getting an excel error message how to avoid it? How can i check within the macro if that file exists and open only when it exists?

    this is my code
    and epdb_confirm.txt does not exist i want to check before hand that if it exists then only open this file else display some error message.
    Thanks



    ChDir "C:ERA_EFT"
    Workbooks.OpenText Filename:="C:ERA_EFTDAFEPDB_CONFIRM.TXT", Origin:= _
    xlWindows, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
    xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, Semicolon:=False _
    , Comma:=False, Space:=False, Other:=True, OtherChar:="|", FieldInfo _
    :=Array(Array(1, 1), Array(2, 1), Array(3, 1), Array(4, 1), Array(5, 1), Array(6, 1), _
    Array(7, 1), Array(8, 1), Array(9, 1), Array(10, 2), Array(11, 1), Array(12, 1), Array(13, 1 _
    ), Array(14, 1), Array(15, 1), Array(16, 1), Array(17, 1), Array(18, 1), Array(19, 1), Array _
    (20, 1))


    Thanks

  2. #2
    Board Regular
    Join Date
    Mar 2002
    Location
    Cincinnati, Ohio, USA
    Posts
    6,824
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi

    Dim Fs
    Set Fs = CreateObject("Scripting.FileSystemObject")
    If Fs.fileexists("C:ERA_EFTDAFEPDB_CONFIRM.TXT") Then
    'your code here
    End If

    Tom
    [ This Message was edited by: TsTom on 2002-04-22 06:53 ]

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Posts
    91
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Thanks a lot works like a top.

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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