[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

How do I run a Word Macro From VB?

Posted on 2001-08-08
7
Medium Priority
?
196 Views
Last Modified: 2012-08-14
I have a Word template with a macro. This macro makes the report and sends it to the printer.

Does anyone know a way from VB that I can open this template and run the macro automatically?
0
Comment
Question by:kenmck
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 3

Expert Comment

by:daffyduck14mil
ID: 6364545
Yes, you can do it this way:

Make sure you reference the microsoft word object library. Then, using your word object you can use the wdObject.Documents.Add("C:\PathtoTemplate\Template.dot")

Then, you can use wdObject.Run MacroName:="TheMacroThatDoesTheJob"

If you have instantiated word and it's standing by with the template open that has the macro, it should run fine.

Grtz.©

D.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6365975
Call your macro "Auto_open", everytime the user loads the template macro is executed.
Cheers
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6365995
Sorry, call your macro like this (from whitin your template):

Private Sub Document_New()
Call Auto_Open ' Or whatever you name your macro
End Sub
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 300 total points
ID: 6365999
By the way, that macro have to be public.
Cheers
0
 

Author Comment

by:kenmck
ID: 6479149
Cheers that worked fine.

Thanks for your help.
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6479939
Just a question:
If that worked fine, why a "B" grade?
Glad to help you.
Cheers.
0
 

Author Comment

by:kenmck
ID: 6479986
I have the problem of having to make VB wait till Word has opened before it can pass the variables. It works fine but will be better I am assured when using .net.

Cheers
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question