Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there a way to suppress/hide Word Template Bookmarks programmatically?

Status
Not open for further replies.

Statey603

Programmer
Nov 10, 2009
196
US
We have a Word Template with bookmarks and currently the bookmarks get populated by looping through the bookmarks.
-------------------------------------------------------------------------
Code Stub:
// Loop thru all the bookmarks and get and set the text in that bookmark
IF ll_bookmark_count > 0 THEN
FOR i = 1 TO ll_bookmark_count
// Get the text to be set at that bookmark
ls_bookmark_text = wf_get_bookmark(uo_word_doc.of_get_bookmark(i))
NEXT
END IF
-------------------------------------------------------------------------


Template Bookmark Names
--------------------------------------- -----------------------------
[X] Reported: [mm/dd/yyyy] RptdChk, RptdTxt, DateRptd
[ ] Need to contact before [mm/dd/yyyy] CntactChk, CntctTxt, BeforeDt

The users now want a few of the template fields suppressed depending on cetain data conditions. For example, if there is no date in the Date_Reported DB filed, do not show the checkbox [RptdChk], static text [RptdTxt] or the Date Reported [DateRptd]. Essentially do not show the entire line.

I have not been able to figure out how to code this so this line effectively gets suppressed.

I appreciate any suggestions, alternatives, etc.

Thanks,
Bill
 
clarification......
I left out the line of code that assigns the bookmark text to the bookmark.

Code Stub:

Code:
// Loop thru all the bookmarks and get and set the text in that bookmark
IF ll_bookmark_count > 0 THEN
 FOR i = 1 TO ll_bookmark_count
  // Get the text to be set at that bookmark
  ls_bookmark_text = wf_get_bookmark(uo_word_doc.of_get_bookmark(i))
  uo_word_doc.of_set_bookmark_text( uo_word_doc.of_get_bookmark(i), ls_bookmark_text)
 NEXT
END IF

I tired adding logic above the set_bookmark() call to not do anything if the field is the date we are checking and it is NULL, but the checkbox still appears. I guess I have succeeded at suppressing the text piece of this, however, it also uses a linefeed that I would like suppressed.

 
Update.......

I was given permission to remove the checkboxes since only one of the lines will be shown (see example above).

The only real issue that I have now is that I get a blank line for the line that is suppressed. I believe that this is because the bookmarks are still there, they are just blank. If anyone has any suggestions on how to truly suppress bookmarks I appreciate any suggestions.



 
I never figured out how to suppress a bookmark, however, I did come up with a solution.

I originally had 4 separate bookmarks in my template:
- info1_txt, info1_date
- info2_txt, info2_date
The issue that I had was that there are 3 possibilities,
info1/date1 populated
or
info2/date2 populated
or
info1 and info2 and dates populated.

However, the user did not want any blank lines.
I ended up replacing the 4 bookmarks with a single bookmark and then just concatenate the data for info1 and info2.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top