Is this possible?

litestream

Active Member
Joined
Jul 24, 2006
Messages
323
I want to save a copy of a document to my intranet but have a different vba code when the document is closed

I currently have:


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim response As String
response = MsgBox("Do you want to save your changes to the Blue Book?", vbYesNo)
Application.EnableEvents = False
If response = vbNo Then ThisWorkbook.Close SaveChanges:=False
If response = vbYes Then ThisWorkbook.Save
If response = vbYes Then ThisWorkbook.SaveCopyAs "\\store\sites\sprintranet\paper\Blue Book\Blue Book.xls"
If response = vbYes Then ThisWorkbook.Close
Application.EnableEvents = True
End Sub


But I want to have the following on the copy:


Private Sub Workbook_BeforeClose(Cancel As Boolean)
Application.EnableEvents = False
ThisWorkbook.Close SaveChanges:=False
Application.EnableEvents = True
End Sub

Is this possible?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
Couldn't you check the workbook's Path within your existing code and act accordingly, eg:

Code:
If Instr(1, ThisWorkbook.Path, "sprintranet") > 0 Then
'    Code if on IntraNet
Else
'    Code if not on IntraNet
End If
 
Upvote 0

Forum statistics

Threads
1,214,651
Messages
6,120,738
Members
448,988
Latest member
BB_Unlv

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