Jump to content

AutoIt and officeviewer/dsoframer problem


Recommended Posts

Hi,

I am learning to use AutoIt recently. I am trying to write an AutoIt script that automates some tasks in another program, which is written in VB. The application hosts a Word document inside the Microsoft dsoframer/Edraw office viewer, which is an ActiveX component. While trying to use _WordAttach, AutoIt fails to do so, but it can detect the document if it is opened in Microsoft Word window and return a valid reference to the Word App. Any idea to get Word application reference that is embedded in an ActiveX component?

Thanks in advance

Link to comment
Share on other sites

  • 4 months later...

Working with a similar situation, I have found that Word applications in a DSOFramer control will not express a window object or Windows collection.

You can still get the object, though, with something like:

$Word = ObjGet("", "Word.Application")
    While not IsObj($Word)
        $Word = ObjGet("", "Word.Application")
        sleep(20)
    WEnd

Now, instead of trying to find windows under this object, try to use documents. For example:

$Word.Application.Activedocument.Activewindow.View.DisplayBackgrounds = True
    $Word.Application.Activedocument.Background.Fill.ForeColor.ObjectThemeColor = 13 ;wdThemeColorText1
    $Word.Application.Activedocument.Background.Fill.ForeColor.TintAndShade = 1
    $Word.Application.Activedocument.Background.Fill.ForeColor.RGB = 16777215 ; RGB(255, 255, 255)
    $Word.Application.Activedocument.Background.Fill.Visible = -1 ; msoTrue
    $Word.Application.Activedocument.Background.Fill.Solid
    $Word.Application.Activedocument.Range.Font.ColorIndex = 0; wdAuto

For can also enumerate through the $Word.Documents collection using parameters like the .Name parameter to find the exact document that you want.

The bummer is that without Window object expressed, window properties like .Visible etc are not available if it is in the DSOFramer control. However, there are plenty of useful document properties. I am still playing with this.

You will need some error handling to keep COM errors from crashing you code. You can get some ideas from Word.au3 to make your own error handler, it doesn't have to be as comprehensive as what is in Word.au3.

Hope this gets you in the right direction.

Edited by wliebkem
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...