Re: COM OLE Automation bridge; property Name not supported
Hello Jörg, Am 29.08.2014 10:17, schrieb Jörg Schmidt: From: Peter Eberlein [mailto:pet@refofd.verwalt-berlin.de] because aoo cannot open all Word docs without crashing (https://issues.apache.org/ooo/show_bug.cgi?id=125419), I wanted to let do WinWord the job. I need to know the names of all bookmarks. So StarBasic looks like this: wordInstance = CreateObject("Word.Application") wordDoc = wordInstance.documents.open("c:\test.docx") For i = 1 To wordDoc.Bookmarks.Count bookmark = doc.Bookmarks(i) msgbox bookmark.Name 'fails 'if the property has arguments: msgbox bookmark.hasProperty("Name") 'false [1] msgbox bookmark.getValue("Name") 'property not supported next Any idea how to get the bookmarks name? I think "Name" is a key word and can not be used in StarBasic. ".Name" Is imho correctly. I do not know where the problem comes, I think there is perhaps bug in the automation bridge of OO. Yes, I have to stand corrected. "bookmarks(index).range.text" fails too, so it is not a key word problem. May be index access doesn't work. count is a valid property of the bookmarks object. You can try the following: Sub main( ) oleService = createUnoService("com.sun.star.bridge.OleObjectFactory") WSH= oleService.createInstance("MSScriptControl.ScriptControl") WSH.Language = "VBScript" vbs=vbs+"Set objWord = CreateObject(""Word.Application"")"+Chr(10) vbs=vbs+"objWord.Visible = True"+Chr(10) vbs=vbs+"Set objDoc = objWord.Documents.Open(""D:\testdokument2.doc"")"+Chr(10) vbs=vbs+"Set xx = objDoc.Bookmarks"+Chr(10) vbs=vbs+"xxx = xx.Count"+Chr(10) vbs=vbs+"For i = 1 To xxx"+Chr(10) vbs=vbs+"k = k & xx(i).Name & CHR(13)"+Chr(10) vbs=vbs+"Next" WSH.ExecuteStatement(vbs) msgbox WSH.CodeObject.k End Sub This Windows Scripting Host workaround did it, Thanks Peter - To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org For additional commands, e-mail: api-h...@openoffice.apache.org
Re: COM OLE Automation bridge; property Name not supported
XRay is the better way, but it's a COM object, which have all the same properties and methods (e.g. invoke(), hasProperty()). hasProperty("Name") returns false. O.K. But reading at the site behind your posted link; what returns hasMethod( "Name" ) ? - To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org For additional commands, e-mail: api-h...@openoffice.apache.org
Re: COM OLE Automation bridge; property Name not supported
> From: Peter Eberlein [mailto:pet@refofd.verwalt-berlin.de] > because aoo cannot open all Word docs without crashing > (https://issues.apache.org/ooo/show_bug.cgi?id=125419), I > wanted to let > do WinWord the job. > > I need to know the names of all bookmarks. > So StarBasic looks like this: > > wordInstance = CreateObject("Word.Application") > wordDoc = wordInstance.documents.open("c:\test.docx") > For i = 1 To wordDoc.Bookmarks.Count > bookmark = doc.Bookmarks(i) > msgbox bookmark.Name 'fails > 'if the property has arguments: > msgbox bookmark.hasProperty("Name") 'false [1] > msgbox bookmark.getValue("Name") 'property not supported > next > > > > > Any idea how to get the bookmarks name? > I think "Name" is a key word and can not be used in StarBasic. ".Name" Is imho correctly. I do not know where the problem comes, I think there is perhaps bug in the automation bridge of OO. You can try the following: Sub main( ) oleService = createUnoService("com.sun.star.bridge.OleObjectFactory") WSH= oleService.createInstance("MSScriptControl.ScriptControl") WSH.Language = "VBScript" vbs=vbs+"Set objWord = CreateObject(""Word.Application"")"+Chr(10) vbs=vbs+"objWord.Visible = True"+Chr(10) vbs=vbs+"Set objDoc = objWord.Documents.Open(""D:\testdokument2.doc"")"+Chr(10) vbs=vbs+"Set xx = objDoc.Bookmarks"+Chr(10) vbs=vbs+"xxx = xx.Count"+Chr(10) vbs=vbs+"For i = 1 To xxx"+Chr(10) vbs=vbs+"k = k & xx(i).Name & CHR(13)"+Chr(10) vbs=vbs+"Next" WSH.ExecuteStatement(vbs) msgbox WSH.CodeObject.k End Sub Greetings, Jörg P.S. @Peter Mir fiel Dein Name gleich ins Auge und die Domain "verwalt-berlin.de" ist ja heute noch Dieselbe wie vor 10 Jahren, denn ich habe nachgesehen und von Dir einen Code-Schnipsel von November 2011 in meiner Sammlung der damals noch über die users-Liste von de-ooo kam. - To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org For additional commands, e-mail: api-h...@openoffice.apache.org
Re: COM OLE Automation bridge; property Name not supported
Moin Mathias, Am 29.08.2014 08:23, schrieb Mathias Röllig: Good morning Peter! Having no Windows and no Word I cannot test your code. Try: bookmark = wordDoc.Bookmarks(i) GlobalScope.BasicLIbraries.loadLibrary( "Tools" ) writeDBGinfo( bookmark ) If there is nothing go step by step writeDBGinfo( wordDoc ) XRay is the better way, but it's a COM object, which have all the same properties and methods (e.g. invoke(), hasProperty()). hasProperty("Name") returns false. Regards Peter - To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org For additional commands, e-mail: api-h...@openoffice.apache.org
Re: COM OLE Automation bridge; property Name not supported
Good morning Peter! Having no Windows and no Word I cannot test your code. Try: bookmark = wordDoc.Bookmarks(i) GlobalScope.BasicLIbraries.loadLibrary( "Tools" ) writeDBGinfo( bookmark ) If there is nothing go step by step writeDBGinfo( wordDoc ) to find the right properties. Regards, Mathias - To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org For additional commands, e-mail: api-h...@openoffice.apache.org
Re: COM OLE Automation bridge; property Name not supported
Hi Mathias, it's only a typo, meant wordDoc.Bookmarks(i) the error "property or method not found" occurs in line msgbox bookmark.Name Regards Peter meant Am 28.08.2014 18:03, schrieb Mathias Röllig: Hi Peter! If you using the right syntax (I don't know): For i = 1 To wordDoc.Bookmarks.Count ^^^ bookmark = doc.Bookmarks(i) ^^^ msgbox bookmark.Name 'fails 'yes, it must 'Option Explicit enabled? Regards, Mathias - To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org For additional commands, e-mail: api-h...@openoffice.apache.org - To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org For additional commands, e-mail: api-h...@openoffice.apache.org
Re: COM OLE Automation bridge; property Name not supported
Hi Peter! If you using the right syntax (I don't know): For i = 1 To wordDoc.Bookmarks.Count ^^^ bookmark = doc.Bookmarks(i) ^^^ msgbox bookmark.Name 'fails 'yes, it must 'Option Explicit enabled? Regards, Mathias - To unsubscribe, e-mail: api-unsubscr...@openoffice.apache.org For additional commands, e-mail: api-h...@openoffice.apache.org