View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
equiangular equiangular is offline
external usenet poster
 
Posts: 67
Default writing a text file in the same folder as my program

If activeworkbook has not been saved, the curdir will be MyDocuments

Takashi Yamauchi wrote:
Could someone helps me?

I'm trying to write data on "TestData.txt", but place "TestData.txt" in the
same folder as my Excel program is placed.


Private Sub SaveThisSubInforGlobal()
Sheets("Response_2").Select

Open "TestData.txt" For Append As #1


Write #1, Cells(i, 1).Value; Cells(i, 2).Value; Cells(i, 3).Value

Close #1
End Sub


I find "TestData.txt" sometimes in the same folder as my Excel program is
placed, but also sometimes in "My Document." It is not consistent. Why is
this so? Is there any way I can place "TestData.txt" in the same folder as
my program is placed? I could do this easily with VB.6, but Excel VBA is
not consistent....


Thank you