Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default filedialog in conjunction with printing to a text file

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default filedialog in conjunction with printing to a text file

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 40
Default filedialog in conjunction with printing to a text file

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
printing a quotation mark in a text file stephen Excel Programming 3 October 24th 07 06:56 PM
Return file name only from FileDialog PMC1 Excel Programming 2 August 10th 06 05:28 PM
FileDialog to select file Acid-Sky Excel Discussion (Misc queries) 2 September 12th 05 06:53 PM
Using FileDialog or GetOpenFileName To Allow File Creation WhyIsDoug Excel Programming 1 July 28th 05 05:14 PM
Excel v10. Extra lines printing to Text file SMS - John Howard Excel Programming 1 May 5th 05 01:16 PM


All times are GMT +1. The time now is 03:42 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"