View Full Version : Solved: Email code crashes if workbook isn't saved
Djblois
05-07-2007, 09:45 AM
I use some email code and it works perfectly 98% of the time. However, if the workbook hasn't been saved yet it crashes. So, I decided to test this code:
VBA:
If ThisWorkbook.Saved = False Then Error00_01_04.Show End If
VBA tags courtesy of www.thecodenet.com (http://www.thecodenet.com/)
and Error00_01_04 shows up all the time. Even if the workbook has been saved before?
lucas
05-07-2007, 09:47 AM
Why not just save it with the code..?
Djblois
05-07-2007, 09:50 AM
Because if the user has never done a Save-As before.
lucas
05-07-2007, 09:50 AM
If ThisWorkbook.Saved = False Then
MsgBox "Save this workbook before proceeding"
End If
Daniel I can't believe you were actually able to even run the code you posted in post#1......
Djblois
05-07-2007, 10:16 AM
Lucas,
it wasn't on one line, when I copied it over I didn't relieze it messed up like that. It is supposed to be:
Sub Error00_01_04code()
If ThisWorkbook.Saved = False Then
Error00_01_04.Show
End If
End Sub
Unfortunately, it always shows up even if it has been saved.
Simon Lloyd
05-07-2007, 10:24 AM
Sub Error00_01_04code()
If ThisWorkbook.Saved <> False Then
Else: Error00_01_04.Show
End If
End Subthis worked for me, unsaved and i got the UF saved i got nothing!
Regards,
Simon
Djblois
05-07-2007, 10:40 AM
Activeworkbook.saved works for me
I guess by using Thisworkbook it was looking at the add-in workbook
Simon Lloyd
05-07-2007, 10:43 AM
Its quite possible, glad its solved for you!
Regards,
Simon
lucas
05-07-2007, 11:01 AM
always use activeworkbook in your addins as thisworkbook will refer to the addin....
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.