I was wondering how to call a macro or execute VBA code in HTML. Why would
I want to do this? My first application is changing my Outlook Today page.
More complex applications involve SharePoint. I can fumble my way around
FrontPage and modify some HTML, but I get stumped at the more complex
things.
As an example, I would like to create a button labeled "Send Message" on the
Outlook Today page that will simply call an existing macro (Send_Message)
that creates (Set objMsg = Application.CreateItem(olMailItem) and displays
(objMsg.Display) a new mail item using all of my default settings. How do I
use the input tag to refer to my macro?
Can I put VBA code in a HTML page? I know I how to do it for JavaScript and
VBScript although I can't write VBScript. That way I would not have to
create macros for everything. I suppose another way would be to call a
function or subroutine from the page. How do I do that?
Thanks for the assistance,
Mark
________________________________
Mark Milliman
Longmont, Colorado E-mail: mark.milliman@comcast.net
________________________________
As you already know, web page code needs to be VBScript or JScript. If you have a VBA procedure that is a Public Sub or Function in the built-in ThisOutlookSession module, you can try instantiating an Outlook.Application object and then invoking it as olApp.MyProcedure. But that's an unsupported technique; there's no guarantee it will work from a web page.
TIP: If you have an Outlook View Control on the web page, use the Application object that it exposes.

Signature
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
>I was wondering how to call a macro or execute VBA code in HTML. Why would
> I want to do this? My first application is changing my Outlook Today page.
[quoted text clipped - 12 lines]
> create macros for everything. I suppose another way would be to call a
> function or subroutine from the page. How do I do that?
Mark Milliman - 13 Sep 2005 18:49 GMT
Sue:
Thanks for your prompt response. Could you please provide some example HTML
code to illustrate your point? I am not that good at HTML coding. It
should work because I can open folders, but that is through a URL like
outlook:inbox.
Please take a look at http://www.outlookcode.com/codedetail.aspx?id=889 when
you have a chance. I had a VBA for Outlook question as well.
Thanks!
Mark
As you already know, web page code needs to be VBScript or JScript. If you
have a VBA procedure that is a Public Sub or Function in the built-in
ThisOutlookSession module, you can try instantiating an Outlook.Application
object and then invoking it as olApp.MyProcedure. But that's an unsupported
technique; there's no guarantee it will work from a web page.
TIP: If you have an Outlook View Control on the web page, use the
Application object that it exposes.

Signature
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
>I was wondering how to call a macro or execute VBA code in HTML. Why would
> I want to do this? My first application is changing my Outlook Today
[quoted text clipped - 16 lines]
> create macros for everything. I suppose another way would be to call a
> function or subroutine from the page. How do I do that?
Sue Mosher [MVP-Outlook] - 13 Sep 2005 19:19 GMT
The Outlook: URL syntaxt for opening folders is completely unrelated.
I don't do much HTML coding either, but if you don't have the OVC, it would be somethign like:
Sub RunMyVBAProc()
Set olApp = CreateObject("Outlook.Application")
olApp.MyProcedure
End Sub

Signature
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
> Sue:
>
[quoted text clipped - 38 lines]
>> create macros for everything. I suppose another way would be to call a
>> function or subroutine from the page. How do I do that?
Mark Milliman - 14 Sep 2005 04:26 GMT
So you are talking about a VBScript subroutine on my HTML page that calls a
VBA subroutine. Makes sense I guess, but doesn't MS say this is
unsupported?
Thanks for all of your help today!
Mark
The Outlook: URL syntaxt for opening folders is completely unrelated.
I don't do much HTML coding either, but if you don't have the OVC, it would
be somethign like:
Sub RunMyVBAProc()
Set olApp = CreateObject("Outlook.Application")
olApp.MyProcedure
End Sub

Signature
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
> Sue:
>
[quoted text clipped - 45 lines]
>> create macros for everything. I suppose another way would be to call a
>> function or subroutine from the page. How do I do that?
Sue Mosher [MVP-Outlook] - 14 Sep 2005 13:54 GMT
Yes, it's unsupported, but it's what you asked how to do.

Signature
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
> So you are talking about a VBScript subroutine on my HTML page that calls a
> VBA subroutine. Makes sense I guess, but doesn't MS say this is
[quoted text clipped - 64 lines]
>>> create macros for everything. I suppose another way would be to call a
>>> function or subroutine from the page. How do I do that?
Mark Milliman - 14 Sep 2005 18:10 GMT
Yeah, but it only works when the VBE has been initialized. It took me two
hours to figure it out! I really need to convert the Set_Account function
to a VBScript and put in in my HTML page.
Thanks,
Mark
Yes, it's unsupported, but it's what you asked how to do.

Signature
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
> So you are talking about a VBScript subroutine on my HTML page that calls
> a
[quoted text clipped - 69 lines]
>>> create macros for everything. I suppose another way would be to call a
>>> function or subroutine from the page. How do I do that?