Save as Range Macro

sassysteph434

New Member
Joined
Jul 24, 2022
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hi,

Not sure if this can be fixed.. so I have a macro that saves the file as the value in A1 then sends it as an attachment. The issue i'm having is lets say the user runs the macro, then realizes that they needed to make an adjustment before they close out of the doc.. I'm getting a runtime error message that says cannot access the doc. However, if i changed the value in a1 and ran the macro it works, and if i change it back to the value that it could not find previously it will give me the prompt that the file already exists and if id like to overwrite the doc. Is there anything i can do to get it to do that the first time around (when im getting that error message
Below is the VBA and the link to the doc.

t.xlsm?)

Any help would be greatly appreciated

Sub Macro2()
'
' Macro2 Macro
'
' Keyboard Shortcut: Ctrl+k
'
ActiveWorkbook.SaveAs Filename:=(Range("A1").Value), FileFormat:=xlOpenXMLWorkbookMacroEnabled
Application.Dialogs(xlDialogSendMail).Show
Application.WindowState = xlMinimized
Application.WindowState = xlNormal
End Sub
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.

Forum statistics

Threads
1,214,904
Messages
6,122,169
Members
449,070
Latest member
webster33

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