ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   VBE Editor opens automatically when I run a macro (https://www.excelbanter.com/excel-programming/377987-vbe-editor-opens-automatically-when-i-run-macro.html)

[email protected]

VBE Editor opens automatically when I run a macro
 
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


michael.beckinsale

VBE Editor opens automatically when I run a macro
 

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


Bob Phillips

VBE Editor opens automatically when I run a macro
 
You can force it to break on the actual error.

In the VBIDE, goto ToolsOptions, 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)

"michael.beckinsale" wrote in message
ups.com...

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




michael.beckinsale

VBE Editor opens automatically when I run a macro
 

Bob,

Thanks. You learn something every day!

Is there any down side to this action?

Regards

Michael Beckinsale


Tim Lindsley

VBE Editor opens automatically when I run a macro
 
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

Bob Phillips wrote:
You can force it to break on the actual error.

In the VBIDE, goto ToolsOptions, 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)

"michael.beckinsale" wrote in message
ups.com...

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



Tim Lindsley

VBE Editor opens automatically when I run a macro
 
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.

wrote:
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




All times are GMT +1. The time now is 12:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com