LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How to edit text in MS Word HEADER using bookmarks?

I've been using the ActiveX calls to edit text in Word docs for a while. I assumed there was no trick to doing it in the header of a Word doc, but there seems to be no way to get into the header via LabView ActiveX calls.

 

Regretably, Word also makes this tricky. I found these VBA hints:

Bookmark, Go to Bookmark:
(This method does not work with bookmarks in Headers/Footers)

Selection.GoTo What:=wdGoToBookmark, Name:="Name"

 

Bookmark, Select a Bookmark:
(This method works when using bookmarks in Headers/Footers)

ActiveDocument.Bookmarks("BookmarkName").Select

 

Bookmark, Insert Text Using Range (Change Content of Range):
(This method works when using bookmarks in Headers/Footers)

ActiveDocument.Bookmarks("BookmarkName").Range.Text="Text"

 

Bookmark, Insert Text Using Range (Add After Range):
(This method works when using bookmarks in Headers/Footers)

ActiveDocument.Bookmarks("BookmarkName").Range.InsertAfter _
   "Text"

 

I have been using the first one and I was hoping one of the last three would be simple to implement, but there does not seem to be a way to do any of them via LabView.

 

 I do not have the reports tool kit, but I have seen nothing to indicate that it is possble with that either.

 

So, is it possible to edit the headed of a MS Word doc?

0 Kudos
Message 1 of 6
(7,312 Views)

I'm also not happy about word and LabVIEW and I hope that there will be much more improvement with the open document format... right know I have to use a word document template :(.

 

However, here is a code I use to fill bookmarks even in the header. I found that somehow the bookmark vanish after manipulation and you have to add it again.

Hope that it help ....

lv_word_bookmark.png

Greetings from Germany
Henrik

LV since v3.1

“ground” is a convenient fantasy

'˙˙˙˙uıɐƃɐ lɐıp puɐ °06 ǝuoɥd ɹnoʎ uɹnʇ ǝsɐǝld 'ʎɹɐuıƃɐɯı sı pǝlɐıp ǝʌɐɥ noʎ ɹǝqɯnu ǝɥʇ'


0 Kudos
Message 2 of 6
(7,302 Views)

Henrik,

 

Thank you very much for the (potential) solution. I do not have the Report Generation Toolkit so I could not see what your VI did. I was hoping to determine if I could build the same functionality from ActiveX calls. I then downloaded the evaluation version of RGT and tried to look at the block diagram of the RGT subVI in your VI. Unfortunately, I can't see that unless I purchase the RGT.

 

Any thoughts on this?

 

I just need to know if this is something I can build and do not know how yet, or if this is truely special to RGT.

0 Kudos
Message 3 of 6
(7,267 Views)

It seems like the ActiveX calls you mentioned in the OP are on the right track.  Take a look at this example of modifying some properties of Microsoft Word, and see if you can do something similar to edit the header.

 

http://decibel.ni.com/content/docs/DOC-12508

0 Kudos
Message 4 of 6
(7,249 Views)

Hi Henrik_Volkers,

 

I am new in Labview and I have to create a report using a template for a project.

Using the Report Generator Toolkit I first had to fix an issue with the limited number of bookmarks (limited to 17) than can be append in a word or excel file MS Office Report Block. I manage to fix this issue thanks to the .vi created by Eric Davenport (http://forums.ni.com/t5/LabVIEW/How-can-I-use-more-than-17-inputs-using-MS-Office-Report-express/td-...

but once my bookmarks are filled with some texts or pictures the links with the cross-references are lost and the cross-references sections not filled in the word template...

Looking for possible solutions, I found your work. I am currently trying to add your .vi to the one of  Eric Davenport with my modifications, but I have to plug a OBJET type (green chain type like in the "report in" and "report out" input and output for all the Report Generator tools)  instead of a DOC type like you have specified in your .vi. I tried to substitute OBJ to your DOC (doc out, range...) type but the Invoke Nodes and Property Nodes do not accept the OBJ...

Is there any way to change this ?

 

Thank you for your time and consideration

0 Kudos
Message 5 of 6
(5,393 Views)

A number of the methods that you reference in your Post come from fairly old versions of LabVIEW, certainly before the new Report Object model was introduced to the Report Generation Toolkit.  It is much simpler to use the RGT, provided you do not use the Express VIs (which, as you have discovered, impose limitations).

 

Can you describe what you want to do?  What kind of report are you trying to create?  Are you creating it "from scratch", or is there an existing Word document (with known bookmarks) into which you have to "insert data"?

 

I've used the RGT to create two kinds of Reports -- Excel Workbooks (both reading and writing them) and HTML Reports, which I use when I want "nice-looking text".  I confess I've not (yet) done much with Word in LabVIEW ...

 

Bob Schor

0 Kudos
Message 6 of 6
(5,338 Views)