VBA to name the active workbook and save it to the desktop of different users computers

parkerbelt

Active Member
Joined
May 23, 2014
Messages
377
I have a spreadsheet that has a value in a cell that I'm calling WMWeek. The value will change, but is currently 201736

I'm trying to save the active spreadsheet with the following file name to the desktop of the person who is running the program: Weekly Report - 201736.xlsx .

I'm using the following code, but when I run it, I'm getting Run-time error '1004' The specified dimension is not valid for the current chart type at the line ActiveWorkbook.SaveAs emailReport:

WMWeek = Cells(Cells(Rows.Count, "A").End(xlUp).Row, 1).Value
emailReport = Environ("HomeDrive") & Environ("HomePath") & "\Desktop\Weekly Report - " & WMWeek & ".xlsx"
ActiveWorkbook.SaveAs emailReport
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I found a solution:

Dim emailReport As String
emailReport = Environ("USERPROFILE") & "\Desktop" & "Weekly Report - " & WMWeek & ".xlsx"
ActiveWorkbook.SaveAs Filename:=emailReport, FileFormat:=xlTextPrinter, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
 
Upvote 0

Forum statistics

Threads
1,215,430
Messages
6,124,846
Members
449,194
Latest member
HellScout

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