GetSaveAsFileName saves empty worksheet

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

Guest

I have a file that I will be downloading daily from a website, formatting it,
then uploading it to another application. I've written the VBA code to do
the formatting, but when I get to the GetSaveAsFileName command, it saves the
blank "personal" worksheet instead of the one I just formatted. I understand
that it's because I have the module written in the "personal" worksheet,
where I chose to place it because I will be working with a new file every
day. Can you offer suggestions on the best way to save the active worksheet
with the data? The worksheet will be named according to the value in cell
a2, which is actually a date in text format.

Thanks again for your assistance!
 
Jenny,

As far as I can tell you just have to make sure you are referencing the
right file to save. This might help:

'this is in your personal.xls
Option Explicit
Sub SaveOtherBook()
Dim vFile As Variant
Dim wbToSave As Workbook
vFile = Application.GetSaveAsFilename
If vFile = False Then Exit Sub
vFile = vFile & "xls"
Set wbToSave = Workbooks(ThisWorkbook.Sheets(1).Cells(2, 1).Value)
Application.DisplayAlerts = False
wbToSave.SaveAs CStr(vFile)
Application.DisplayAlerts = True
End Sub

Robin Hammond
www.enhanceddatasystems.com
 
...when I get to the GetSaveAsFileName command,
it saves the blank "personal" worksheet ...

GetSaveAsFileName doesn't actually Save anything.
All it does is return a filename. It's then up to you to use that filename
for whatever you wish. Typically, you'd use it to specify the filename
argument of the Save or SaveAs methods.


Regards,
Vic Eldridge
 

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

Similar Threads


Back
Top