Save As not working for me

jcg31

Board Regular
Joined
Aug 20, 2006
Messages
176
I have an application that requires two workbooks to be open.
Workbook one is named "Data"
It is used to generate two spreadsheets that are then copied to a new workbook that vba creates I then want to save that workbook as SalesData_08272011. That workbook is then mailed to a number of folk (that part is working fine)
It is the save as that I am having trouble with

dateid is the variable for the date string at end of file

The following code doesn't halt the program it crashes excel - - no idea why

wName = Workbooks.Item(2).Name
Workbooks(wName).SaveAs Filename:="C:\Sales\PaywallActivity" & "_" & dateid & ".xls"

Any help would be appreciated.
Jim
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
What is the code that creates the data in dateID? You need to be very careful in constructing date strings so they do not include illegal characters.
Rich (BB code):
Dim DateID as String

DateID = "SalesData_" & Format(Date, "MMDDYYYY") & ".xls"


Also, is the PaywallActivity meant to be part of the filename, or it a folder? If folder, you are missing the final \ in that string.
Rich (BB code):
Workbooks(wName).SaveAs Filename:="C:\Sales\PaywallActivity\" & "_" & DateID
 
Last edited:
Upvote 0
datehldr=Sheet1.ComboBox1.text
sepr = Split(datehldr, "/")
dateid = sepr(0) & sepr(1) & sepr(2)

Sorry my earlier post was in error the line below should have been the code offered and the only one causing the issue (C:\Sales\ is the only folder)

Workbooks(wName).SaveAs Filename:="C:\Sales\SalesData_" & DateID & "*.xls"


What is the code that creates the data in dateID? You need to be very careful in constructing date strings so they do not include illegal characters.
Rich (BB code):
Dim DateID as String

DateID = "SalesData_" & Format(Date, "MMDDYYYY") & ".xls"


Also, is the PaywallActivity meant to be part of the filename, or it a folder? If folder, you are missing the final \ in that string.
Rich (BB code):
Workbooks(wName).SaveAs Filename:="C:\Sales\PaywallActivity\" & "_" & DateID
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,181
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top