Breakpoint will not stop Excel subroutine

B

boswald

I have a routine (CreateTextFile) that accepts a type variable, an
saves the selected cells as a csv or tab file, giving a message box a
the end "file xxx saved".

I have attached it to a toolbar button, with the assigned macro a
'CreateTextFile("tab")".

When I click the button, the macro runs twice - it displays the msgbo
twice.

So it inserted a breakpoint, and the code doesn't stop, it just run
twice anyway.

I found an entry in this forum - "Breakpoint will not stop Exce
function" posted "03-08-2004, 03:50 PM", but the question of why th
breakpiont gets ignored was not answered.

Does anyone have any ideas why a breakpoint will be ignored?

This routine is definately being run by pressing the button, and if
call it from another short subroutine and pass it "tab" or "csv" i
runs only once, and breakpoints or single stepping work fine.

Thanks,

boswal
 
B

Bob Phillips

The only thing that I can think of is that the code exits before the
breakpoint, or is bypassed by an IF or a GOTO.

What does the code look like.

--

HTH

RP
(remove nothere from the email address if mailing direct)
 
T

Tushar Mehta

If you are using the syntax =CreateTextFile("tab") for a button's
OnAction setting, for some reason XL runs the code twice. See a
concurrent discussion in .office.developer.vba titled "OnAction setting
for menu item" including how I would code the statement.

As far as the breakpoint bit goes, put a breakpoint at the very *first*
line of code in the routine -- or if necessary use the Stop statement.
Then, step through the code with F8 and check what happens.

--
Regards,

Tushar Mehta
www.tushar-mehta.com
Excel, PowerPoint, and VBA add-ins, tutorials
Custom MS Office productivity solutions
 

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