W
wayne ingalls
I have an Excel file with some custom userforms that collect various
data to populate two worksheets. After the user has finished entering
all data, I'd like to be able to let the user click on a command button
to automate saving the file in CSV format.
I have looked at the example in the online help which shows how to write
the code for saving as text. The online help doesn't bother telling you
how to save in other formats, but I was able to generate an example for
part of what I needed by recording a macro.
I'm stuck at trying to guess the syntax for the file filter to only
allow the user to save in CSV format.
I'm using Office X and need it to work for both PC and Mac users.
I believe this should work for a PC user:
fName = Application.GetSaveAsFilename(fileFilter:="CSV (*.csv), *.csv")
I have tried this and other combinations similar to the line above for
Mac users, but get runtime errors (fileFilter:="TEXT" will work, but I
don't want to save as plain text):
fName = Application.GetSaveAsFilename(fileFilter:="CSV")
This portion of my code seemed to work, but if there's a better way, I'm
open to suggestions:
If fName <> False Then
Worksheets("Sheet1").SaveAs FileName:=fName, FileFormat:=xlCSV
End If
Thanks in advance for any help. It would be great if applications still
came with printed manuals, or acceptable if there were online manuals.
Unfortunately most software companies don't seem to think it's worth
documenting how to use their products.
-wayne
data to populate two worksheets. After the user has finished entering
all data, I'd like to be able to let the user click on a command button
to automate saving the file in CSV format.
I have looked at the example in the online help which shows how to write
the code for saving as text. The online help doesn't bother telling you
how to save in other formats, but I was able to generate an example for
part of what I needed by recording a macro.
I'm stuck at trying to guess the syntax for the file filter to only
allow the user to save in CSV format.
I'm using Office X and need it to work for both PC and Mac users.
I believe this should work for a PC user:
fName = Application.GetSaveAsFilename(fileFilter:="CSV (*.csv), *.csv")
I have tried this and other combinations similar to the line above for
Mac users, but get runtime errors (fileFilter:="TEXT" will work, but I
don't want to save as plain text):
fName = Application.GetSaveAsFilename(fileFilter:="CSV")
This portion of my code seemed to work, but if there's a better way, I'm
open to suggestions:
If fName <> False Then
Worksheets("Sheet1").SaveAs FileName:=fName, FileFormat:=xlCSV
End If
Thanks in advance for any help. It would be great if applications still
came with printed manuals, or acceptable if there were online manuals.
Unfortunately most software companies don't seem to think it's worth
documenting how to use their products.
-wayne