template file to be saved as xlsm workbook with file name as a cell reference

bellajn

New Member
Joined
May 11, 2020
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hi everyone
I'm a relative novice at VBA coding and can use some assistance. I have a template file (saved as xltm) that i want to save as an "xlsm" file with the file name referenced to cell "G1".

This is the code that I wrote but i have a 1004 error appearing for the "method "SaveAs" of object "_workbook" failed

Sub Save_File()
Dim FileName As String
Dim Path As String
Application.DisplayAlerts = False
Path = "G:\RT SEQ RMC\SUNSHINE COAST\02. ADMINISTRATION\RMC Weekly Claims\Testing\"
FileName = Range("G1").Value & ".xlsm"
ActiveWorkbook.SaveAs Path & FileName, xlOpenXMLWorkbookMacroEnabled
Application.DisplayAlerts = True
ActiveWorkbook.Close
End Sub

I am using Office 365.

Any advice?

Thanks
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hi and welcome to MrExcel

Path = "G:\RT SEQ RMC\SUNSHINE COAST\02. ADMINISTRATION\RMC Weekly Claims\Testing\"
FileName = Range("G1").Value & ".xlsm"

Does the folder exist?
Literally what you have in cell G1, that is, put here the content of your cell G1 of the active sheet.
Is cell G1 empty?
What data do you have inside cell G1?
 
Upvote 0
Hi DanteAmor

Thanks for responding :)

Yes the folder does exist and there is a formula that creates the file name located in cell G1
File location.PNG

Cell reference.PNG


Thanks :)
 
Upvote 0
Remove the ":" from the file name and try again.
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,734
Messages
6,126,542
Members
449,316
Latest member
sravya

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