Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Object Variable with Block variable not set message

I am trying to run this code on workbook open and get the above error message

mode = EssVGetGlobalOption(5)

For Each ctl In CommandBars("essoption").Controls
If mode = 4 And (ctl.Caption Like "Warnings*") Then
ctl.Caption = "Warnings Off"
ElseIf mode = 2 And (ctl.Caption Like "Warnings*") Then
ctl.Caption = "Warnings On"
End If
Next ctl

the error is on the line For Each ctl In CommandBars("essoption").Controls

thanks


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4,624
Default Object Variable with Block variable not set message

VBA doesn't think that the Commandbar "essoption" exists.

In article ,
Nigel wrote:

I am trying to run this code on workbook open and get the above error message

mode = EssVGetGlobalOption(5)

For Each ctl In CommandBars("essoption").Controls
If mode = 4 And (ctl.Caption Like "Warnings*") Then
ctl.Caption = "Warnings Off"
ElseIf mode = 2 And (ctl.Caption Like "Warnings*") Then
ctl.Caption = "Warnings On"
End If
Next ctl

the error is on the line For Each ctl In CommandBars("essoption").Controls

thanks

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 772
Default Object Variable with Block variable not set message

As with your problem yesterday, we have to know what
mode = EssVGetGlobalOption(5)
is, the For Next code is fine, i built the custom toolbar and everything, it
is good.
If i set mode to 4 i get warnings off, if i set it to 2 i get warnings on,
so it has to be the EssVGetGlobalOption(5) that is causing the issue.

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Nigel" wrote:

I am trying to run this code on workbook open and get the above error message

mode = EssVGetGlobalOption(5)

For Each ctl In CommandBars("essoption").Controls
If mode = 4 And (ctl.Caption Like "Warnings*") Then
ctl.Caption = "Warnings Off"
ElseIf mode = 2 And (ctl.Caption Like "Warnings*") Then
ctl.Caption = "Warnings On"
End If
Next ctl

the error is on the line For Each ctl In CommandBars("essoption").Controls

thanks


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 141
Default Object Variable with Block variable not set message

the code works fine when added to an addin and everything works as it should.

What I wanted to do is as a spreadsheet options check the settings and then
adjust the button caption on the toolbar, the ESSVGETGLOBALOption is setting
the mode correctly (to 4) if thats is the value

I actually just put the code into a module and it works fine there so it
must be in the sub routine it doesn't like it


"John Bundy" wrote:

As with your problem yesterday, we have to know what
mode = EssVGetGlobalOption(5)
is, the For Next code is fine, i built the custom toolbar and everything, it
is good.
If i set mode to 4 i get warnings off, if i set it to 2 i get warnings on,
so it has to be the EssVGetGlobalOption(5) that is causing the issue.

--
-John
Please rate when your question is answered to help us and others know what
is helpful.


"Nigel" wrote:

I am trying to run this code on workbook open and get the above error message

mode = EssVGetGlobalOption(5)

For Each ctl In CommandBars("essoption").Controls
If mode = 4 And (ctl.Caption Like "Warnings*") Then
ctl.Caption = "Warnings Off"
ElseIf mode = 2 And (ctl.Caption Like "Warnings*") Then
ctl.Caption = "Warnings On"
End If
Next ctl

the error is on the line For Each ctl In CommandBars("essoption").Controls

thanks


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
Runtime Error 91 Object variable or With block variable not set. Tim Excel Programming 9 June 5th 08 10:03 PM
Need help with Error 'object variable or with block variable not set' Francois via OfficeKB.com Excel Programming 5 April 30th 07 03:05 PM
Getting inconsistent Error 91-Object variable or With block variable not set mfq Excel Programming 0 December 14th 05 06:08 PM
Run-time error '91': "Object variable or With block variable not set Mike[_92_] Excel Programming 2 December 30th 04 10:59 AM
Cells.Find error Object variable or With block variable not set Peter[_21_] Excel Programming 2 May 8th 04 02:15 PM


All times are GMT +1. The time now is 05:15 PM.

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"