Save if Modified Before Print

Lace29M

New Member
Joined
Jul 20, 2007
Messages
5
I need to create a command to tell Excel to Save my Workbook BeforePrint, if and only if the Workbook has been modified since the last time it was saved. Right now I have a command that runs where a text box is populated with the last date modified BeforeSave. The date modified will not change unless modifications to the workbook are saved. Therefore, I want to keep the last date modified the same when the Workbook is opened and printed if the Workbook has not been modified. Please Help!
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Do you mean something like:

Code:
Private Sub Workbook_BeforePrint(Cancel As Boolean)
Dim wb As Workbook
If Not wb.Saved Then
    wb.Save
End If
Set wb = Nothing
End Sub

placed in the 'ThisWorkbook' VBA object?
 
Upvote 0
Just for the record, the line
Code:
Set wb = ThisWorkbook
should have been included before the IF statement
 
Upvote 0

Forum statistics

Threads
1,214,787
Messages
6,121,558
Members
449,038
Latest member
Guest1337

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