GetSaveAsFilename not working in Excel 2003

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am having trouble with a macro that worked in Excel 2000 but will not work
in Excel 2003. In 2000, this macro saves just the data portion but in 2003
it loops endlessly. I also have trouble with a few more macros. Is there a
place where I can go to find variances between Excel 2000 VBA and 2003?

Do
answer = Application.GetSaveAsFilename(InitialFilename:="InitFile",
FileFilter:="Text Files (*.txt), *.txt", Title:="SAP Upload File Name")
Loop Until answer <> False
Worksheets("sheet1").SaveAs filename:=answer
 
Hi

Is the complete code ?
Do you want to save the sheet as a txt file ?

Try this

Sub test()
Dim wb As Workbook
Do
answer = Application.GetSaveAsFilename(InitialFileName:="InitFile", _
FileFilter:="Text Files (*.txt), *.txt", Title:="SAP Upload File Name")
Loop Until answer <> False
Worksheets("sheet1").Copy
Set wb = ActiveWorkbook
ActiveWorkbook.SaveAs Filename:=answer, FileFormat:=xlText
wb.Close False
End Sub
 
This is the complete code. My problem isn't with the SaveAs, it is with the
Application.GetSaveAsFilename function.
 
Since it worked for you, I have to assume that the problem is with our
company's installation of Excel 2003. I wasn't even getting to
"Worksheets("sheet1").SaveAs filename:=answer".

By the way, to answer your question, I was trying to save the sheet with the
given name as a text file (tab delimited).
 
By the way, to answer your question, I was trying to save the sheet with the
given name as a text file (tab delimited).

Use my first example then that copy the sheet into a new workbook and save it
 
Change
ActiveWorkbook.SaveAs Filename:=answer, FileFormat:=xlText

to
wb.SaveAs Filename:=answer, FileFormat:=xlText
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top