Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi I'm trying to adapt a macro that "saves" a spreadsheet as pipe-delimited
text. The macro I've found on the web does what it says on the tin, but has a hard-coded file name, Open "C:data.txt" For Output As #1 and at a certain point in the macro, it use the line Print #1, CurrTextStr to save the data. I was hoping to find a way to get the user to detemine the output path/filename rather than having it hard-coded, but I just don't understand the filedialog syntax well enough to make it work. Can anyone help with this? Many thanks, Geoff. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Dim myFileName As Variant
myFileName = Application.GetSaveAsFilename _ (InitialFileName:="C:\myfile.txt", _ filefilter:="Text Files, *.txt") if myfilename = false then exit sub 'user hit cancel end if .... open myfilename for output as #1 ... print #1, currtextstr ====== You don't need the initialfilename if you don't want it. Geoff C wrote: Hi I'm trying to adapt a macro that "saves" a spreadsheet as pipe-delimited text. The macro I've found on the web does what it says on the tin, but has a hard-coded file name, Open "C:data.txt" For Output As #1 and at a certain point in the macro, it use the line Print #1, CurrTextStr to save the data. I was hoping to find a way to get the user to detemine the output path/filename rather than having it hard-coded, but I just don't understand the filedialog syntax well enough to make it work. Can anyone help with this? Many thanks, Geoff. -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Many thanks, that was perfect.
Geoff. "Dave Peterson" wrote: Dim myFileName As Variant myFileName = Application.GetSaveAsFilename _ (InitialFileName:="C:\myfile.txt", _ filefilter:="Text Files, *.txt") if myfilename = false then exit sub 'user hit cancel end if .... open myfilename for output as #1 ... print #1, currtextstr ====== You don't need the initialfilename if you don't want it. Geoff C wrote: Hi I'm trying to adapt a macro that "saves" a spreadsheet as pipe-delimited text. The macro I've found on the web does what it says on the tin, but has a hard-coded file name, Open "C:data.txt" For Output As #1 and at a certain point in the macro, it use the line Print #1, CurrTextStr to save the data. I was hoping to find a way to get the user to detemine the output path/filename rather than having it hard-coded, but I just don't understand the filedialog syntax well enough to make it work. Can anyone help with this? Many thanks, Geoff. -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
printing a quotation mark in a text file | Excel Programming | |||
Return file name only from FileDialog | Excel Programming | |||
FileDialog to select file | Excel Discussion (Misc queries) | |||
Using FileDialog or GetOpenFileName To Allow File Creation | Excel Programming | |||
Excel v10. Extra lines printing to Text file | Excel Programming |