ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   GetSaveAsFileName saves empty worksheet (https://www.excelbanter.com/excel-programming/334992-getsaveasfilename-saves-empty-worksheet.html)

Jenny Barker

GetSaveAsFileName saves empty worksheet
 
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!

Robin Hammond[_2_]

GetSaveAsFileName saves empty worksheet
 
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

"Jenny Barker" wrote in message
...
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!




Vic Eldridge[_3_]

GetSaveAsFileName saves empty worksheet
 
...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



"Jenny Barker" wrote:

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!



All times are GMT +1. The time now is 08:07 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com