Save as Cell to Loctacion

Mr_Adams

Active Member
Joined
Oct 7, 2002
Messages
475
I am trying to come up with a VBA that save the Worbook as A cell Value "V4".
The following works great in a standard workbook but I can't seem to get it to work in Template.
This is what I have so far

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ThisFile = Range("V4").Value
ActiveWorkbook.SaveAs Filename:=ThisFile
ActiveWorkbook.SaveAs Filename:="M:InvoiceInvoices" & ThisFile
End Sub

I have also tried

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
ThisFile = Range("V4").Value
ActiveWorkbook.SaveAs Filename:=ThisFile
ActiveWorkbook.SaveAs FileName:="M:InvoiceInvoices" & ThisFile & ".xls", FileFormat _
:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False
End Sub

Both seem to wotk for Workbooks, but not Templates

Any Ideas?
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
Solution

Private Sub Workbook_BeforeClose(Cancel As Boolean)
' ********************************************************
' * Forces Database update and saves new file as the Invoice Number *
' ********************************************************

Application.Run "commit"
ActiveWorkbook.SaveAs FileName:="M:\Invoices\Invoices\" & Range("V4")
End Sub
 
Upvote 0
Is this the longest time between the first two posts in history... 6 months!!! Good job for solving your problem Mr_Adams.

LT
 
Upvote 0

Forum statistics

Threads
1,223,227
Messages
6,170,857
Members
452,361
Latest member
d3ad3y3

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