How do I link a macro to a CommandButton in a custom form, want us

C

Cybordelic

I would like to map a macro to a button in a custom form that I have
designed. I already have the vbscript, which I got off of the VBScript
section of the MS website, and it works just fine. The script asks the user
if they want to visit the conference booking site, and when they click on yes
it opens the appropriate page. I just can't seem to figure out how to map
the macro to a button, so that when a user clicks the button in the form they
are asked if they want to visit the site, when they click yes an IE browser
windows opens directly to our conference booking site. I am trying to do
this using a CommandButton that I have inserted into my form, which I got
from the controls toolbox.

I am new at this and perhaps I am be trying to do something that cannot be
done in Outlook 2000, but I am not sure. I seem to remember using a form
once that had a button built into it that opened a webpage.

Any advice is appreciated.

Please advise.

Thank-you,
Charles
 
S

Sue Mosher [MVP-Outlook]

You need to be using not a VBA macro but VBScript code attached to your
button's Click event:

Sub CommandButton1_Click()
' your code goes here
End Sub
 
C

Cybordelic

Thank-you for responding to my question. Where do I find the button's Click
event? I don't see it under the "CommandButton1" Properties or Advanced
Properties.
 
S

Sue Mosher [MVP-Outlook]

You have to create the event handler by typing the code into the form's View
Code window.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
C

Cybordelic

Excellent! I was successful in inserting the code.

The form works when I run the form and click on the button (opens in
Internet Explorer and goes to the right webpage). But if I save the file
..oft and close the form, then re-open the form and try to click the button is
does nothing. How do I save the form so that the button will work when I
open the form or send it to my co-workers pc.

The idea is that we want to allow all users to be able to double click the
..oft and open the form, fill it out, and send it the address that is already
populated in the To: field.

Thanks again!
Charles
 
S

Sue Mosher [MVP-Outlook]

Code doesn't run in one-off or unpublished forms. The right procedure
depends on whether you are working in an Exchange environment and, if so, if
you can publish to the Organizational Forms library. See
http://www.outlookcode.com/d/formsec.htm

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
C

Cybordelic

When I click on your hyperlink below I get the message "The page cannot be
found".
 
C

Cybordelic

Thank-you for all of your help Sue!
Since I cannot publish to the "Organizational Forms Library" due to
permissions, what I have suggested as a solution for those people who will
need to use the form is this: first I emailed it to them, then they can
Publish the form and save it in their Personal Form library, and then they
can open the custom form from there. This seems to be working ok. Would you
recommend I do this differently? Can you see a problem with this method?

Charles
 
S

Sue Mosher [MVP-Outlook]

That should work just fine. Congratulations on writing what must have been
clear instructions!

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
C

Capone2377

I am working on something similar Cybordelic and was wondering if you could
send me a link to the VBscript you got from microsoft.

Thanks,
 
T

Thaddaeus Parker

Use the OnAction function when you have captured the specific
commandbarbutton that you want. the OnAction format is usually in the form
of a text statement eg

commandBarButton.OnAction = "<!" + someMacroName + ">";
 

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