PDA

View Full Version : Help with "IF...Then" within a Word document



thegreg
06-17-2010, 05:22 PM
Hi everyone, I'm kinda stuck on something that seems like it should be simple enough, but it's not working for me. I have these documents that use bookmarks that are automatically filled in with a doctor's name and a signature line above the bookmark. I'd like to have the signature line only appear if the bookmark is filled in. So it'd be something like this

(I'm using QuickParts->Fields->If)

{IF cosignature = (this is where I’m stuck) “_____________” “ “\* MERGEFORMAT}

Is it something simple like - If cosignature <> NULL or something? It doesn't seem to want to work for me. Any ideas here would be great!!!

Thanks!!!

thegreg
06-17-2010, 05:30 PM
I forgot to specify, but I'm using Word 2007, in case that matters.

Also, the document looks kinda like this right now...


____________________
[cosignature bookmark]


And after then end user acts on it, it looks like this...

____________________
John Smith, M.D.



Thanks again!!!

macropod
06-18-2010, 12:15 AM
Hi John,

You could use something like:
{IF cosignature <> "" "_____________"}

I assume the 'cosignature' bookmark is in a formfield. If so, make sure the formfield's 'calculate on exit' property is set and that you have whatever the default value for the formfield is between the first pair of double quotes. Usually, that's 5 spaces, for which your field code would become:
{IF cosignature <> " " "_____________"}

Note: You don't need the '\* MERGEFORMAT' switch.

FWIW, you skip the can skip the QuickParts->Fields->If route and hand-code the field by pressing Ctrl-F9, then inserting the required code between the field braces. It's much easier to nest fields this way.

Tinbendr
06-18-2010, 05:14 AM
Another option would be to encapsulate the line and the title inside the bookmark and use the font's hidden property.

ActiveDocument.Bookmarks("DrSig").Range.Font.Hidden = False

fumei
06-18-2010, 01:42 PM
Please clarify.

"I'd like to have the signature line only appear if the bookmark is filled in. "

That does not match what you later state.

____________________
[cosignature bookmark]


THAT seems like the line is there to start with. In case, how about this? Demo attached. You do not state exactly how information is to be passed to the bookmark. I used a userform. Click "Show Userform" on the top toolbar. If you select nothing (no text),nothing happens. If you select an item from the list, and click OK, the text is inserted, and the paragraph above becomes lined.

fumei
06-18-2010, 01:50 PM
Version2: it becomes a toggle.

Click OK with an item, the bookmark has the text, the paragraph above is lined.

Click OK with nothing, if the bookmark currently has text it is removed; the paragraph above, if lined, becomes unlined.

thegreg
06-21-2010, 01:06 PM
Thanks for the help so far. I still can't get it working correctly. To answer some of the questions here... the bookmarks are being populated by an xml file.

Macropod, the solution you posted is along the lines of what I need, but for some reason, whether the bookmark is filled in or not, I still get the signature line. Any ideas?

Thanks so much for the help everyone, I really appreciate it!!

fumei
06-23-2010, 09:40 AM
"Thanks for the help so far. I still can't get it working correctly."

And what does that actually mean. I just tested the file I posted and it works precisely, exactly, as you state you want.

"filled in with a doctor's name and a signature line above the bookmark. I'd like to have the signature line only appear if the bookmark is filled in. "

It fills in the name, and a line above if a name is selected. if a name is NOT selected, there is no name, or line above.

EXACTLY as you state you want. It does not help at all when you state it is not "working correctly". That does not tell us anything. What is not working correctly? What is happening that is not correct?