Sign in to follow this  
Followers 0
Maphizto

Office Menu call / com background

3 posts in this topic

I'm trying to get an automated PDF Conversion to work. For this I need to open Word/Excel/Powerpoint and call the Adobe PDF Maker Makro.

My first approach was to fiddle around with "Send". Worked kind of okay until the screensaver kicked in and left me with no active window.

Up next was SendControl which didn't work at all. I was probably a little to impatient with the custom menus that are being used in office.

After discovering the beta Version that supported ObjCreate I made this little script here..

$word = ObjCreate("Word.Application")

; open document
$word.Documents.Open("testfile.doc")
$word.Visible = True
$word.Activedocument.Saved = True

; try to find the pdf maker control
For $ii = 1 to $word.CommandBars.Count
    $bar = $word.CommandBars($ii)
    If $bar.Name = "PDFMaker 7.0" Then
        For $jj = 1 to $bar.Controls.Count
            $item = $bar.Controls($jj)
            If $item.TooltipText = "&Convert to Adobe PDF" Then
            ; button found, start PDF Maker
                msgBox(0,"Info", "Found PDF Maker at " & $ii & "." & $jj, 2)
                $item.Execute()
                msgBox(0,"Info", "Conversion started", 2)
            EndIf
        Next
    EndIf
Next

It works fine until the conversion is being started.. It won't return to the Script until the whole conversion finished. That is a huge problem because I need to check for Error messages or set timeouts so the script won't wait for ever due to nasty user inputs that might appear during conversion.

Is there a way to give those com calls timeouts or force them to return immediately? Usually you want return values, but in this case I just want to fire up the conversion and then continue with my script.

Any info or thoughts are appreciated

Regards

Share this post


Link to post
Share on other sites



What about doing some kind of quasi-multi-threading? You could call a separate script that has the other functionality that you want running in the background while your PDF conversion is going on, and only then start the conversion. (Or the other way round - have your conversion script as a subscript.)

I've not used ObjCreate or anything that advanced, so I've no idea whether it has timeouts built in or not.

ben

Share this post


Link to post
Share on other sites

It works fine until the conversion is being started.. It won't return to the Script until the whole conversion finished. That is a huge problem because I need to check for Error messages or set timeouts so the script won't wait for ever due to nasty user inputs that might appear during conversion.

<{POST_SNAPBACK}>

Welcome Maphizto,

AdlibEnable()

TimerInit()

TimerDifF()

WinExists()

These functions, if used within an Adlib function may help with your problem.

Support forum is good place for these problems, thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0