General discussion

Locked

Macro works on toolbar but not in Word

By hurdk ·
I have a Word document
I have a working macro on the toolbar
I have a Visual Basic command button on the Word document
I copy the code from the tool bar to the command button
I click on the command button and get error
"User-defined type not defined"
This error relates to the code:
Dim oOutlookApp As New Outlook.Application
Thank you.

This conversation is currently closed to new comments.

6 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Macro works on toolbar but not in Word

by Lord Ago 1 In reply to Macro works on toolbar bu ...

Sounds like you're missing the declaration for that type in the button which is what causes this kind of error. The toolbar would have it but the button won't see it unless you put it into the button where needed.

Have Fun!!!

Collapse -

Macro works on toolbar but not in Word

by hurdk In reply to Macro works on toolbar bu ...

Poster rated this answer

Collapse -

Macro works on toolbar but not in Word

by Peyison In reply to Macro works on toolbar bu ...

First off - please rate the other answers I've left for you. :)

I believe this problem relates to the fact that you copied the macro from your Word document, to the "Normal" template. This is because you saved your new toolbar in Normal - so thatis where the code will exist.

In your original document you must have had a reference to the Outlook library. You need to add the same reference to Normal. To do this:

Open the VB editor (Tools -> Macros -> Visual Basic Editor)

You'll see a reference for the Normal project in the Project window. Select it.

Choose Tools -> References and check Microsoft Outlook xx Object Library.

You should be good to go.

Hope this helps.

Collapse -

Macro works on toolbar but not in Word

by Peyison In reply to Macro works on toolbar bu ...

woops. Looks like I got it backwords. You're moving from the toolbar to a command button. You'll need to add the reference to the new Word doc that contains the command button.

Collapse -

Macro works on toolbar but not in Word

by hurdk In reply to Macro works on toolbar bu ...

This answer is correct and was very useful to me.

Collapse -

Macro works on toolbar but not in Word

by hurdk In reply to Macro works on toolbar bu ...

This question was closed by the author

Back to Web Development Forum
6 total posts (Page 1 of 1)  

Related Discussions

Software Forums