I am trying to open a .docx file from dxl and am having a little trouble. I hacked this code together - I have no idea what I am doing here so this is probably going to be some of the worst code you will ever see - and it is not quite working. When I call the function, MS Word opens up fine but the specific .docx file doesn't open. Any thoughts?
void openWordDoc(string docName){
// declarations
OleAutoObj objWord = oleCreateAutoObject("Word.Application")
olePut(objWord, "Visible", true)
OleAutoObj objDoc = null
oleGet(objWord, "Documents", objDoc)
OleAutoArgs args = create()
// open file
put(args, docName)
oleMethod(objDoc, "Open", args)
clear args
// clean up
put(args, 1)
oleMethod(objWord, "Close", args)
oleMethod(objDoc, "Close", args)
delete(args)
oleCloseAutoObject objWord
oleCloseAutoObject objDoc
}
SystemAdmin - Wed Jul 27 16:44:31 EDT 2011 |
Re: opening word from dxl |
Re: opening word from dxl string NameFile = "c:/MyFolder\\MyOtherFolder\\MyWordDoc.docx" string NameWord = "C:\\Program Files\\Microsoft Office\\Office12\\WinWord.exe" system(NameWord " " NameFile) This is much like using the command prompt. It opens the file with word but there is no communication channel. Hassle when you install a new version of Word. For text files its easy, since "notepad.exe" is in the default path: system("NotePad.exe " NameFile)
This may be better: string NameWord = getRegistry("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Office\\12.0\\Common\\InstallRoot", "Path") What I WAS doing is searching all over the place until I found WinWord.exe if (null NameWord) getRegistry("HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Office\\11.0\\Common\\InstallRoot", "Path") |
Re: opening word from dxl the simplest way to open the document is to use the activateURL function. It will let windows determine the assigned application ;-) Best regards from Berlin Reik _______________________Evosoft GmbH / Siemens AG |
Re: opening word from dxl Reik_Schroeder - Thu Jul 28 04:12:52 EDT 2011 -Adam |