Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing Variable to Open Statement (XP)

    Is it possible to pass a variable to the following statement: Open MyFile & ".csv" For Output as #1

    I would like to pass a variable to "Output"

    As an example: Open MyFile & ".csv" For oVar as #1
    oVar = "Append"
    or
    oVar = "Output"


    I have tired it and can't quite seem to get it to work.

    Thanks,
    John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Passing Variable to Open Statement (XP)

    No, because the argument to Open is not a string but a keyword. Howver, you can do this:

    If oVar = "Append" Then
    Open MyFile & ".csv" For Append As #1
    Else
    Open MyFile & ".csv" For Output As #1
    End If

  3. #3
    Silver Lounger
    Join Date
    Dec 2000
    Location
    California, USA
    Posts
    1,758
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Passing Variable to Open Statement (XP)

    Hans,

    Thanks for the suggestion.

    John

Posting Permissions

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