Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default Error message

Good day, i have a form and have disabled the "X" close button with the
code below. Since i have done that, my cancel button does not work ?
When i click on it i get the following error message " Run time error
'91'" "Object variable or with block variable not set". Could somebody
please help, i am not sure what i have done wrong.

'--------------- Close Button ----------------------------
Private Sub userform_QueryClose(Cancel As Integer, closeMode As Integer)
If closeMode = vbFormControlMenu Then
MsgBox "Please click on the cancel button to close the
document", 0, "ZA-T-M-22"
Cancel = True
End If
End Sub
'--------------- Cancel Button
------------------------------------------------
Private Sub CmdCancel_Click()
Application.DisplayAlerts = False
Unload Me
Application.Quit
End Sub

Tempy

*** Sent via Developersdex http://www.developersdex.com ***
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Error message

Works with me mate. Anything else going on?

--
HTH

Bob Phillips

"Tempy" wrote in message
...
Good day, i have a form and have disabled the "X" close button with the
code below. Since i have done that, my cancel button does not work ?
When i click on it i get the following error message " Run time error
'91'" "Object variable or with block variable not set". Could somebody
please help, i am not sure what i have done wrong.

'--------------- Close Button ----------------------------
Private Sub userform_QueryClose(Cancel As Integer, closeMode As Integer)
If closeMode = vbFormControlMenu Then
MsgBox "Please click on the cancel button to close the
document", 0, "ZA-T-M-22"
Cancel = True
End If
End Sub
'--------------- Cancel Button
------------------------------------------------
Private Sub CmdCancel_Click()
Application.DisplayAlerts = False
Unload Me
Application.Quit
End Sub

Tempy

*** Sent via Developersdex http://www.developersdex.com ***



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default Error message

Hi Bob,

I got the error message to go away when pressing cancel by just having
Application.Quit, but now it appears after my code has run, when i click
on debug it then goes half into debug but then the application closes,
as i am not a taught programmer i am totally bamboozled ?

Tempy

*** Sent via Developersdex http://www.developersdex.com ***
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 203
Default Error message

Hi Bob, found the problem thanks :-)

Tempy

*** Sent via Developersdex http://www.developersdex.com ***
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,120
Default Error message

What was it, so we may know if someone else gets it.

--
HTH

Bob Phillips

"Tempy" wrote in message
...
Hi Bob, found the problem thanks :-)

Tempy

*** Sent via Developersdex http://www.developersdex.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
VBA Error Message "Compile Error...." Steve Excel Discussion (Misc queries) 3 July 15th 05 09:20 AM
Excel XP error message Run Time Error 91 Lenny[_3_] Excel Programming 1 March 3rd 05 10:15 PM
changing the message in an error message The Villages DA Excel Worksheet Functions 2 February 18th 05 05:30 PM
How do I get rid of "Compile error in hidden module" error message David Excel Discussion (Misc queries) 4 January 21st 05 11:39 PM
VBA Error Message Dave Excel Programming 2 September 24th 04 02:21 PM


All times are GMT +1. The time now is 08:51 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"