Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Code Problem in BeforeSave Event

I've got this code in the BeforeSave event of my workbook:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)

If MsgBox("Have you researched and manually entered the correct" _
& vbNewLine & "amounts for Proceeds from" _
& " Sale of PPE?", vbYesNo, "Reminder") = vbYes Then
ActiveWorkbbook.Save
Else
Sheets("Cash Flow").Select Range("B25").Select

End If
End Sub

When I get my MsgBox and click YES, I get a run time error and the code
stops on the ActiveWorkbook.Save line.
If I click NO, the workbook saves, despite the fact I only want to go to a
specific cell. How do I fix this code so when I click TES the workbook
saves, and when I click NO it goes to the specified cell?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Code Problem in BeforeSave Event

Try adding 'Cancel = True' on the line after 'Else'


"Kirk P." wrote in message
...
I've got this code in the BeforeSave event of my workbook:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

If MsgBox("Have you researched and manually entered the correct" _
& vbNewLine & "amounts for Proceeds from" _
& " Sale of PPE?", vbYesNo, "Reminder") = vbYes Then
ActiveWorkbbook.Save
Else
Sheets("Cash Flow").Select Range("B25").Select

End If
End Sub

When I get my MsgBox and click YES, I get a run time error and the code
stops on the ActiveWorkbook.Save line.
If I click NO, the workbook saves, despite the fact I only want to go to a
specific cell. How do I fix this code so when I click TES the workbook
saves, and when I click NO it goes to the specified cell?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 66
Default Code Problem in BeforeSave Event

Now the NO button works fine, but the YES button still bombs out on the
ActiveWorkbook.Save line.

"Steve" wrote:

Try adding 'Cancel = True' on the line after 'Else'


"Kirk P." wrote in message
...
I've got this code in the BeforeSave event of my workbook:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

If MsgBox("Have you researched and manually entered the correct" _
& vbNewLine & "amounts for Proceeds from" _
& " Sale of PPE?", vbYesNo, "Reminder") = vbYes Then
ActiveWorkbbook.Save
Else
Sheets("Cash Flow").Select Range("B25").Select

End If
End Sub

When I get my MsgBox and click YES, I get a run time error and the code
stops on the ActiveWorkbook.Save line.
If I click NO, the workbook saves, despite the fact I only want to go to a
specific cell. How do I fix this code so when I click TES the workbook
saves, and when I click NO it goes to the specified cell?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 39
Default Code Problem in BeforeSave Event

Since this is on a 'Before Save' event, you don't need the Active
Workbook.Save line.


"Kirk P." wrote in message
...
Now the NO button works fine, but the YES button still bombs out on the
ActiveWorkbook.Save line.

"Steve" wrote:

Try adding 'Cancel = True' on the line after 'Else'


"Kirk P." wrote in message
...
I've got this code in the BeforeSave event of my workbook:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As
Boolean)

If MsgBox("Have you researched and manually entered the correct" _
& vbNewLine & "amounts for Proceeds from" _
& " Sale of PPE?", vbYesNo, "Reminder") = vbYes Then
ActiveWorkbbook.Save
Else
Sheets("Cash Flow").Select Range("B25").Select

End If
End Sub

When I get my MsgBox and click YES, I get a run time error and the code
stops on the ActiveWorkbook.Save line.
If I click NO, the workbook saves, despite the fact I only want to go
to a
specific cell. How do I fix this code so when I click TES the workbook
saves, and when I click NO it goes to the specified cell?






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Event (BeforeSave) - How to test VBA code? Dave P. can you hear me now? EagleOne Excel Discussion (Misc queries) 3 September 14th 06 07:46 PM
BeforeSave event Carl Bowman Excel Discussion (Misc queries) 4 February 6th 05 12:28 PM
BeforeSave sub won't save another workbook when triggered by another event sub Brad Yundt Excel Programming 1 June 3rd 04 03:12 AM
BeforeSave event j23 Excel Programming 0 April 6th 04 11:15 AM
BeforeSave workbook event Cindy Excel Programming 15 February 10th 04 04:28 PM


All times are GMT +1. The time now is 10:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"