Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Where am I going wrong

I have a spreadsheet which is updated by the user clicking
a button on the sheet. I don't want them to be able to
close the workbook without them updating, so I've disabled
the x.
However, on one sheet it gives them the option of opening
another workbook, but when they do this my code doesn't
work.

public ConTrolClose

Private Sub Workbook_Open()
ConTrolClose = True
End Sub

Private Sub Workbook_BeforeClose(Cancel As Boolean)
Select Case ConTrolClose
Case True
Cancel = True 'cant close workbook
Case False
Cancel = False ' can close workbook
End Select
End Sub

Private Sub cmdSheet1_Click()
Range("i1") = Time
ThisWorkbook.Save
UserForm1.Show
End Sub

Private Sub cmdSheet2_Click()
Range("i1") = Time
ThisWorkbook.Save
UserForm1.Show
End Sub

Private Sub cmdCloseWorkbook_Click()
ConTrolClose = False
Select Case ActiveSheet.Name
Case "Sheet1"
If MsgBox("Do you need to open Data", vbYesNo) = vbYes Then
Workbooks.Open "C:\Windows\Desktop\Data.xls", , , , "lrp"
If ActiveWorkbook.ReadOnly = True Then
MsgBox ("You cannot update at this time")
Application.Quit
Else
ThisWorkbook.Close
End If
End If
Case Else
Application.Quit
End Select
End Sub


Private Sub cmdReturntosheet_Click()
Unload Me
ConTrolClose = True
End Sub

The problem is with cmdCloseWorkbook
If Sheet1 is active then clicking this should give you the
option of either quitting or opening the workbook Data and
closing this one. It opens Data but doesn't close.

Any help much apprecitated

Libby

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Where am I going wrong


Perhaps something like this would be easier to handle :-
'------------------------------------------------------
rsp = MsgBox("Do you need to open Data", vbYesNoCancel)
Select Case rsp
Case vbYes
'do something
Case vbNo
'do something else
Case vbCancel
'do something else
End Select
End Sub
'-----------------------------------------------------

-----------------------------------------------
~~ Message posted from http://www.ExcelTip.com
~~View and post usenet messages directly from http://www.ExcelForum.com

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
What's wrong in this Eqn? Raz Excel Worksheet Functions 1 January 12th 10 07:27 PM
Insert Calculated Field (wrong Qty*Price = wrong Amount) Edmund Excel Discussion (Misc queries) 8 October 4th 07 12:13 PM
Any wrong with this? Jo[_2_] Excel Discussion (Misc queries) 1 August 2nd 07 09:48 PM
What am I doing wrong? Jeff New Users to Excel 4 March 6th 05 03:05 AM
What am I doing wrong? Jeff Excel Discussion (Misc queries) 6 March 6th 05 03:01 AM


All times are GMT +1. The time now is 08:52 PM.

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

About Us

"It's about Microsoft Excel"