Object Variable with Block variable not set message

N

Nigel

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
 
J

John Bundy

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.
 
N

Nigel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top