VBE Editor opens automatically when I run a macro

W

wtlindsley

Hi!

I'm using a command button in an excel worksheet to show a userform. I
have assigned a macro to the command button. All the macro does is
open a userform named "frmKitForms." The macro is in a standard
module. Here it is:

Sub KitForms()

frmKitForms.Show

End Sub

When I click the command button that runs the macro the VBE Editor
opens and the line of code (i.e. frmKitForms.Show) is highlighted in
yellow. If I click F5, the code opens my userform like normal. If I
step through the code using F8, the code does not proceed to End Sub,
it just goes back to Sub KitForms(), and returns an error when it reads
the frmKitForms.Show line.

Does anyone know why the VBE editor is opening automatically at all?

Regards,

Tim
 
M

michael.beckinsale

Tim,

Unhelpfully if there is a coding error contained in a form the debugger
will the highlight frm.show code line.

I usually find that its the 'initialize' event that causes this but
that wont neceesarily be the case.

Suggest you can try 'commenting out' sections of code to isolate what
causing the problem or if possible paste the code into a normal module
and run from there.

Regards

Mike beckinsale
 
B

Bob Phillips

You can force it to break on the actual error.

In the VBIDE, goto Tools>Options, select the General tab from the dialog,
and set the 'Break in Class Module' button in the 'Error Trapping' frame.

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)
 
M

michael.beckinsale

Bob,

Thanks. You learn something every day!

Is there any down side to this action?

Regards

Michael Beckinsale
 
T

Tim Lindsley

Thank you both for your speedy replies!

Bob: I did as you said, selected "Break Class Module", and there is no
change--it still breaks on the same line of code (i.e. on
frmKitForms.Show).

The strange thing is I can open the VBIDE, go to the procedure and push
F5 (or step through with F8) and everything works fine. The problem
occurs specifically when I run the macro from the cmd btn on my
worksheet.

Any more thoughts are greatly appreciated!

Regards,

Tim
 
T

Tim Lindsley

Posting a reply to my own post.

The problem seems to have been in the different types of command
buttons. One is a forms button, and the other is a control toolbox
command button. The control toolbox command button (look in toolbars
for control toolbox) gets rid of the VBIDE opening...at least I stopped
having the problem when I used the toolbox command button.
 

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