Solved

How to execute a word MACRO from Delphi?

Posted on 2003-11-11
7
1,191 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
  • 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 50 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

ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi exception 7 64
Connection between libmysql.dll and MySQL Versions 7 97
Delphi 2 59
Press three keys together and trigger a function 3 56
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

770 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