Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How to execute a word MACRO from Delphi?

Posted on 2003-11-11
7
Medium Priority
?
1,309 Views
Last Modified: 2010-04-05
Hello All,

           My application is having a OLE continer with a word document as an object. I have created a Word Macro called 'StartUp'. I have to execute this Macro when the word document(Oleobject) is active.

          I tried to execute it like:
                        Olecontiner1.Oleobject.RunMacro('StartUp');
-- But the method RunMacro is not recognized by Delphi.

Could you provide me a suggestion how to execute a macro from Delphi?

Thanks
PVP
0
Comment
Question by:pvp1
[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
  • 2
  • 2
7 Comments
 
LVL 6

Expert Comment

by:DaFox
ID: 9724912
Hi PVP,

WordApplication1.Run('StartUp'); ??

Markus
0
 

Author Comment

by:pvp1
ID: 9724975
Hello Markus!

          With this statement i had a runtime exception. WordObject(OleContinerObject) can not support the Method 'Run' !!!  Is there any method which can support OleObject?

thanks
pvp

0
 
LVL 6

Expert Comment

by:DaFox
ID: 9725122
Don't know, maybe you first have to add the template to the list of templates for the current session.

oleContainer1.OleObject.application.AddIns.Add('C:\{...}StartUp.dot', true);
and after that
application.run("StartUp");

But I'm not really sure about it; just try it ;0)

Markus
0
 

Author Comment

by:pvp1
ID: 9730039
Hello,
     
i tried directly like ..
        oleContainer1.OleObject.application.run('StartUp');

it is able to start executing the Macro, StartUp... but immediately i am getting the runtime error :
           Microsoft Visual Basic, Runtime error: 4605
                      'Thsi method or property is not available because this document is in another application'

could anybody help how to solve this problem?

Thanks
pvp
         

0
 
LVL 9

Accepted Solution

by:
tkalchev earned 200 total points
ID: 9741040
Maybe you can try the following :


var WordApp : OleVariant;

WordApp := GetActiveOleObject ( 'Word.Application' );
WordApp.Run('StartUp');
WordApp := Unassigned;
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

636 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