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

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
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,225,065
Messages
6,182,653
Members
453,130
Latest member
alexos

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