Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MS-Word OLE question

Status
Not open for further replies.

afx

Programmer
Mar 4, 2004
27
CA
I am running a commercial macro (Design Science/MathType) via Win32::OLE that produces a pop-up window that I must manually click "OK".

Is there a way to get the "OK" clicked using OLE or some other method?

 
Here's the code...

use Win32::OLE;
use WIN32::OLE::Const 'Microsoft Word';
my $word;

eval {$word = Win32::OLE->GetActiveObject('Word.Application')};
die "Word not installed" if $@;

unless (defined $word) {
$word = Win32::OLE->new('Word.Application','Quit')
or die "oops, cannot start Word";

$word->{DisplayAlerts} = wdAlertsNone;
my $doc = $word->Documents->Open("D:\\path\file.doc, {Visible => 1})
or die "Cannot open document " . Win32::OLE->LastError;

# AutoOpen macro configured/defined within Word to run
# the ConvertEquations macro - which produces the pop-up
# program ONLY progresses once the OK button on the
# pop-up has been MANUALLY pressed

$doc->SaveAs("D:\\outpath\\file.rtf, {FileFormat => wdFormatRTF});
$doc->Close;

########

# AutoOpen Macro ...

Sub AutoOpen ()
'
' AutoOpen Macro
' the next bit of code is in ONE line
' - just in case it doesn't appear that way!
Application.Run MacroName:="MTCommandsMain.MTConvertEquations.Main"
End Sub

#########

In fact, having just run the ConvertEquations command again I notice that there are TWO OK buttons to press: the first to OK the pop-up (where options can be set/changed) and once the equations have been converted, there's a second pop-up to tell me that it's finished.

Good luck!



regards
Mark H., AFX
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top