![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: extract data at Word-Document-Bookmarks in word-documents. Topic Summary: VBA OleObject propItem ListObject Created On: 25-Jul-2006 13:38 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() |
|
Hi all,
i have a problem with handling of OleObject. I want to implement a vba-statement like ActiveDocument.Bookmarks(1).Select My intention is to extract data at Word-Document-Bookmarks in word-documents. Well, i don't know how to access certain listObject-Items like Bookmarks(1) or Bookmarks("Test"). I tried to handle this listObject like a method, but the result is always null. put(objArgBlock, bookmark) oleMethod(objDoc,"Bookmarks",objArgBlock,oleBookmark) //Bookmarks-Attrpointer string stmp oleGet(oleBookmark,cPropertyName,stmp) oleMethod(oleBookmark,cMethodSelect) now i want to know how it is possible to get a handle of a certain bookmark-object of a word-document thx Edited: 25-Jul-2006 at 13:39 by Thomas Langholz |
|
![]() |
|
![]() |
|
This isn't an exact answer to your question, but it may point you in the right direction. I know this is tough, it took me days to get this to work properly!
The attached code uses constants from utils/ole.inc, but I've had to add considerably to that file. It takes as input the document object from Word, and tweaks the heading numbering for all heading levels. In order to do this, it access items in the ListLevels object, which I think is analgous to what you're trying to do. Feel free to uncomment all the print statements so you can see what it thinks it's doing. Hope it helps! ------------------------- Paul dot Tiplady at TRW dot com TRW Automotive |
|
![]() |
|
![]() |
|
Whatever you want to do in DXL, you should allways try it first in the Word VBA editor (macro editor).
First if you are not familiar with VBA, do a Record New Macro and look at the code it generates (Alt + F11). Also with bookmarks there is always a range attached to it. So, assuming you selected some text ("Hello world") in your document and then inserted a Bookmark named "hw", you can access like so: ActiveDocument.Bookmarks("hw").Range.Text --> this gets the "Hello World" text However, if you did not selected any text when the bookmark was inserted, then Text property is empty, but the Range.Start is located at the location of the bookmark, like so: ActiveDocument.Bookmarks("hw").Range.Start --> is the location of the bookmark And you can do something like so: Dim r as Range set r = ActiveDocument.Bookmarks("hw").Range.Expand --> get the next word in range object then r.Text --> is the word So, consult the VBA editor, and look into the help or the object browser (F2) to see what properties and methods are there for Bookmarks. |
|
![]() |
|
![]() |
|
I would try the following:
--Get the "Bookmarks" object from the document (using oleGet) and store it in another OleAutoObj --Use the "Item" method on the Bookmarks with an arg block of the number or name to get, and store it in another OleAutoObj (which will be your Bookmark) --Then do whatever you need to do on the bookmark Sometimes the straightforward way doesn't work like it seems like it should. When in doubt, be as explicit as possible and make a DXL object for every object in the app you're working with (e.g. one for every single thing in between dots in a VBA statement). The Office documentation is pretty thorough as far as that goes. Also, always use the checkRes function in ole.inc, or something like it. I've extended our version to keep all the errors and print them in the DXL window. Chris |
|
![]() |
|
![]() |
|
thanx @all for fast answers
@chris thats the way i tried myself yesterday and it works! (see attached code) thanx a lot Edited: 26-Jul-2006 at 07:05 by Thomas Langholz |
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.