Welcome to Telelogic Product Support
  Home Downloads Knowledgebase Case Tracking Licensing Help Telelogic Passport
Telelogic DOORS (steve huntington)
Decrease font size
Increase font size
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
Search Topic Search Topic
Topic Tools Topic Tools
Quick Reply Quick Reply
Subscribe to this topic Subscribe to this topic
E-mail this topic to someone. E-mail this topic
Bookmark this topic Bookmark this topic
View similar topics View similar topics
View topic in raw text format. Print this topic.
 25-Jul-2006 13:38
User is offline View Users Profile Print this message


Thomas Langholz

Posts: 40
Joined: 20-Oct-2005

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
Report this to a Moderator Report this to a Moderator
 25-Jul-2006 13:47
User is offline View Users Profile Print this message


Paul Tiplady

Posts: 176
Joined: 28-Oct-2003

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
Report this to a Moderator Report this to a Moderator
 25-Jul-2006 14:44
User is offline View Users Profile Print this message


Octavian Stanescu

Posts: 39
Joined: 28-Feb-2005

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.













Report this to a Moderator Report this to a Moderator
 25-Jul-2006 19:17
User is offline View Users Profile Print this message


Chris Jones

Posts: 177
Joined: 1-Jul-2005

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
Report this to a Moderator Report this to a Moderator
 26-Jul-2006 06:49
User is offline View Users Profile Print this message


Thomas Langholz

Posts: 40
Joined: 20-Oct-2005

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
Report this to a Moderator Report this to a Moderator
Statistics
20925 users are registered to the Telelogic DOORS forum.
There are currently 1 users logged in.
The most users ever online was 15 on 15-Jan-2009 at 16:36.
There are currently 0 guests browsing this forum, which makes a total of 1 users using this forum.
You have posted 0 messages to this forum. 0 overall.

FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.