Join The Works program to have access to the most current content, and to be able to ask questions and get answers from Revelation staff and the Revelation community

At 01 JUN 2007 11:15:04AM Colin Kavanagh wrote:

Anybody know how to return a list of MailMerge Fields from word.

Normally I would loop through the Fields collection in VB/VBA and interrogate the code property.

How can I access each individual field object via OI OLE.

Any help greatly appreciated


At 01 JUN 2007 12:22PM Bob Carten wrote:

There is an excellent article in Sprezzatura's SENL titled An Introduction to the Use of OLE controls from OpenEngine - Part 2 describing how to work with OLE automation and word.

The basic trick with collections such as fields is to get a reference the collection, get the count property, then for i=1 to count, get the item property. The Item property is zero based, so you have to keep that in mind.

something like

collection=OleGetProperty(MainObject, 'CollectionName')

cnt=OleGetProperty(collection, 'Count')

for i=1 to cnt

  element=OleGetProperty(collection, 'Item', i-1)
 Name')

Next

see This example of wlaking through the Bookmarks collection


At 01 JUN 2007 01:09PM Colin Kavanagh wrote:

  • third_party_content/community/commentary/forums_works/a4b435e4615fe464852572ed0053c72d.txt
  • Last modified: 2023/12/30 11:57
  • by 127.0.0.1