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 16 JAN 2009 11:24:49AM Richard Richter wrote:

I am trying to use OLE to place data in a Word document. Admittedly, I have taken the code from Bob Carten and Hank Huizinga. I want to thank them profusely. The data is all defined and I am trying to place the data in a Bookmark called NameAddress. This is the code thus far:

wordApp=OleCreateInstance("Word.Application")

nextHandle=OleGetProperty(wordApp,"DOCUMENTS")

OlePutProperty(wordApp,"VISIBLE",1)

documentHandle=OleCallMethod(nextHandle,"OPEN",MergeDocument)

Selection=OleGetProperty(wordApp,"SELECTION")

oMarks=oleGetProperty(documentHandle, "Bookmarks")

mcnt=oleGetProperty(oMarks, "COUNT")

oMark=OleCallMethod(oMarks, "ITEM", book)

bookmarkname=OleGetProperty(oMark, "Name")

x=OleCallMethod(oMark,"SELECT")

OlePutProperty(Selection, "TYPETEXT", NameAddress)

result=OleCallMethod(wordApp,"PRINTOUT",1)

OlePutProperty(wordApp,"DISPLAYSLERTS",0)

Quit=OleCallMethod(wordApp,"QUIT",0)

Everything runs fine until I try to "SELECT" the bookmark and apply data with "TYPETEXT". Can anybody tell me what I'm doing wrong?

Thanks,

Richard Richter


At 16 JAN 2009 06:41PM Barry Stevens wrote:

]]bookmarkname=OleGetProperty(oMark, "Name")

Should you be using this in any of the following code


At 17 JAN 2009 09:47AM Richard Richter wrote:

Barry,

Thanks for your response. I'm not sure if I need it or not. It does return the name of the bookmark. My problem thus far is highlighting the bookmard so that I can place the text in the bookmark. The "SELECT" line returns a "" response and the bookmark is not highlighted on the word document.

Thanks,

Richard


At 17 JAN 2009 10:22PM Barry Stevens wrote:

]]It does return the name of the bookmark

So, have you tried changing the lines related to bookmark refence to this variable.


At 19 JAN 2009 03:27AM John Taylor wrote:

Im not sure why your code is not working but here is a section of code that I use all the time quite successfully.

oWrd=OleCreateInstance("Word.Application")

OlePutProperty(oWrd,'Visible', ShowWord)

oDocuments=oleGetProperty(oWrd, 'Documents')

oDoc=OleCallMethod(oDocuments, 'OPEN', targetfile)

oActiveDoc=OleGetProperty(oWrd, 'ActiveDocument')

Selection=OWrd-]Selection

* Walk the bookmarks

oMarks=oDoc-]Bookmarks

mcnt=oMarks-]count

for i=1 to mcnt

 oMark=oMarks-]Item(i)
 colname=oMark-]Name   
 convert @lower.case to @upper.case in colname
 locate colname in colnames using @fm setting pos then
 	  Val=ColData
    convert @vm to char(10) in val 
 end else
    val= '
 end     
 x=Omark-]Select()
 x=Selection-]TypeText(val)

next


At 19 JAN 2009 10:34AM Richard Richter wrote:

Thanks for the help guys.

Barry,

Yes I tried that and every combination I could think of without results.

John,

I get an "Illegal expression encountered" when I try to compile "x=Omark-]Select()"

Needless to say, I'm totally confused. Any other ideas would be greatly appreciated.

Richard


At 19 JAN 2009 05:36PM Bob Carten wrote:

Richard

"x=Omark-]Select()"

1. Is there Zero versus letter-O typo?

2. What happens if you use the syntax

 x=OleCallMethod(oMark, 'Select')

- Bob

View this thread on the Works forum...

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