Running VBA Code or Macros in HTML

M

Mark Milliman

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: (e-mail address removed)
________________________________
 
S

Sue Mosher [MVP-Outlook]

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.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
M

Mark Milliman

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.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

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


--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
M

Mark Milliman

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


--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
S

Sue Mosher [MVP-Outlook]

Yes, it's unsupported, but it's what you asked how to do.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
M

Mark Milliman

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.

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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