AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

COM and Word.Application - How do I call "document"

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
hotzenpl0tz



Joined: 22 Oct 2007
Posts: 11

PostPosted: Tue Nov 13, 2007 2:29 pm    Post subject: COM and Word.Application - How do I call "document" Reply with quote

Hello, I am trying to automate the insertion of several values I parsed from a webpage using COM (probably the most reliable way to get this working on several machines, at least I hope so).

I tried the following:

Code:

word := COM_ActiveXObject("Word.Application")
COM_Invoke(word, "visible=", "true")
COM_Invoke(word, "Open", "c:\test.dot")


The "visible" part works. The Open Method doesn't get called, I suspect it is because the visible method is not part of the Word.Application Object, but a sub-object called documents. The vbscript equivalent I would be calling here is:

Code:

Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("c:\scripts\inventory.doc")


Can somebody help me out here, how I would get the handler for the documents object so I can call the method ?
I suspect I would have to do something with COM_Queryinterface and maybe use the IID of the document object ? If so, how do I get the ID ?

Thanks alot !
Back to top
View user's profile Send private message
Sean



Joined: 12 Feb 2007
Posts: 1397

PostPosted: Tue Nov 13, 2007 3:15 pm    Post subject: Re: COM and Word.Application - How do I call "document& Reply with quote

hotzenpl0tz wrote:
Code:
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Open("c:\scripts\inventory.doc")

Verbatim translation:
Code:
objWord := COM_CreateObject("Word.Application")
objDoc  := COM_Invoke(COM_Invoke(objWord, "Documents"), "Open", "c:\scripts\inventory.doc")

Quote:
I suspect I would have to do something with COM_Queryinterface and maybe use the IID of the document object ?

I don't think VBS has the function of QueryInterface.
Back to top
View user's profile Send private message
hotzenpl0tz



Joined: 22 Oct 2007
Posts: 11

PostPosted: Tue Nov 13, 2007 3:34 pm    Post subject: Reply with quote

Thanks alot Sean, helped me out immensely !
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group