View Single Post
  #15   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Kent[_2_] Kent[_2_] is offline
external usenet poster
 
Posts: 7
Default Need to nest HYPERLINK within a complex IF (Word 2003/2007)

On Aug 30, 5:25*am, Peter Jamieson
wrote:
Thanks for posting back.

I would dearly love to pass this example back to the people at Microsoft
(if I could), who I am pretty sure now have the mindset that anyone
trying to do anything of this general nature should be coding it with
.NET and possibly VSTO. /Why/ anyone images that that is either easier
or more secure - particularly when you have to deal with more than one
version of Word - than overhauling the field code system so that it
behaves in a *more predictable and useful way is actually beyond me.

Peter Jamieson

http://tips.pjmsn.me.uk



Kent wrote:
I tested it out, using the INCLUDETEXT "DocProperty includefile"
bookmark. I used macropod's script to figure out what I'd need to do.
The Filename/p \\..\\includefile didn't really work, but the autoexec
macro did, but I still had problems with the LINKs weren't updating
consistently. Then when I moved it to a Sharepoint to test how others
would access it, I was able to modify the DocProperty so it would
work. However, when I tried to build in the steps that a novice would
need to do in order to manage this if they needed to move it to their
local machine, I ran to even more issues. Most of which I was able to
get around, but it got fairly painful... Then after I got it working
(sort of) then everytime I'd refresh the document, the LINKs would
drive me crazy. Sometimes even just opening the document clean, the
LINKs would be screwed up.


So, I went back to square one, with my original context.
{ IF { =OR ( { COMPARE { dd_Service } = "ALL" },{ COMPARE
{ dd_Service } = "abc" } ) } = 1 "For abc - *do this, that and the
other. Refer to { HYPERLINK "https://some.sharepoint.server/folder/
details%20file.doc" } for more details, then update the status and
more..." "" } *-- I figured out two things.


1) After you copy in the Hyperlink into the middle of the text, you
may need to replace the descriptive text for the Link, and reset the
style as a hyperlink. Then select it and update, then toggle to
verify.
2) Readers can see the hyperlink, but it doesn't present with the CTRL-
click to follow it. You just need to right-click, then "Toggle Field
Codes" then they can CTRL-click on the hyperlink. In essence, if the
main document is on one level, the Hyperlink within the IF is down one
level.


It's not quite as clean as being able to follow the link from the top
level, but it doesn't require a bunch of additional coding, extra
include files, or having to rely on what someone else may do with the
include files, or rely on the inconsistency of Word itself....


Best of luck,
Kent


On Aug 25, 2:22 am, Peter Jamieson
wrote:
re. the bullets/numbering, I don't have any more suggestions right now..


re. the INCLUDETEXT thing, you can (rather fortuitously) implement a
"relative addressing" scheme using the { FILENAME \p } field as the
base, e.g. to construct the path of a file in the same folder oas the
including file, use


"{ FILENAME \p }\\..\\includedfilename.doc"


macropod expanded this and wrote it up at


http://www.wopr.com/index.php?showto...70027&#entry67...


I would guess that you can do a


{ SET includedfilepath "{ FILENAME \p }\\..\\includedfilename.doc" }
then
{ INCLUDEFILE "{ includedfilepath }" bookmark }


or something similar.


Peter Jamieson


http://tips.pjmsn.me.uk


Kent wrote:
Peter,
I figured out why I was having problems with the Filename. I thought
it was
the format, but was actually the external Links that the INCLUDETEXT
was
building. Initially when I tested this approach, I was in a higher-
level folder, but
I copied the file and the Incldue file into a new folder, so it broke
the links. Or, it
got confused, since I had tried it out on probably 10 different
slightly different
formats, between running Updates, and making Adjustments, Word had
10+
different links for the same bookmark, and same section of
INCLUDETEXT... I
cleaned them up, and figured out a way to point them to the right
location
using a Hyperlink as part of a SET statement to assign the path to a
variable,
which I then reference within my IncludeText. I put the details in a
Thread over
on Microsoft's site where you were responding to some related
questions on
INCLUDETEXT.
I still have 2 outstanding issues with it, that I can probably just
live with for now...
1) Bulleting/sub-bullets are still hit and miss. It was interesting
that a given bookmark
could be at one bullet level, and contain several sub-bullets, and
maintain numbering of
the sub-bullets when it was included in the main document. The only
problem is that main
bullet doesn't show for some reason, probably because Word is confused
by the mixed
styles. I can split it so I have an Include for the main bullet and
another for the sub-bullets,
and that seems to work a little better, but then the first sub-bullet
doesn't show a number.
2) I'm a bit concerned about all of the external Links that Word is
generating. I'll need to
experiment with this to see what I need to do when I move it to
another folder, like when
I'm ready for others to access it on SharePoint. I'm not sure if I can
simply use my Set
Hyperlink approach, and then when I Select All - F9 if it will replace
them all or if it will
just add to the existing ones, and confuse it again. I'll try a test
on this tomorrow. Otherwise,
I'll need to set up some type of macro to select and delete all of the
Links, so I can rebuild them
or trigger a manual update, or something... Thoughts?
Kent
On Aug 24, 8:05 am, Kent wrote:
Regarding moving the quotes, in our examples the structure looks like:
"{INCLUDETEXT "File_of_Includes" bookmarkforUC_1} "
However, after updating the field (F9) it would sometimes move the
closing quote
following the filename to behind the bookmark, like:
"{INCLUDETEXT "File_of_Includes bookmarkforUC_1"} "
When I started getting the Invalide filename, I noticed that actually
smashed the
bookmark into the end of the filename, so there was no space between
them. I'll try
again this morning.
Is there an order of precedence occuring when you execute the update
(F9 - e.g.
Left-to-Right, inside-out)? I guess I assumed that it wouldn't resolve
and include the
file/bookmark if the condition wasn't met first. But, it's probably
resolving inside-out with
the filename and bookmark first, then determining if it should display
only if the
conditions are true. I'm just speculating based on my earlier life as
a programmer
...a LONG time ago. This is a bit of stretch for me now, but like I
said, I'm trying to keep
it simple for those that I'll be leaving it with.
May be I could pull the filename from a document variable, but it
would
probably have the same problem once it resolved the filename. Worth
checking...
Kent
On Aug 24, 2:56 am, Peter Jamieson
wrote:
* I just wish this SOB would react consistently so I could address the
* issues appropriately.
IKWYM.
* It keeps failing on the
* Filename, when
* I wasn't changing anything
If you are using exactly the same filename for all the includes, I
suppose this is likely to be something to do with what Word does exactly
when it has loads of INCLUDETEXTs loading stuff from the same file. Does
it open the file once? Open multiple copies? Keep it open? Have a timing
problem? It has never been obvious and nor have I tried to use a monitor
to find out. But Word 2007 is far more likely to have problems in this
area as it seems to do a lot more stuff whenever it opens a file (e..g.
caching it locally etc.).
You may be abe to do something with macropod's discovery that you can
use something like
{IF {INCLUDETEXT {IF TRUE "the pathname"}} {INCLUDETEXT {IF TRUE
"the pathname"}}}
to get Word to resolve the INCLUDETEXT fields completely as it goes along.
* it keeps repositioning where the quotes
* are being position (behind
* the Macro reference"
I lost you on this one, sorry...
Peter Jamieson
http://tips.pjmsn.me.uk
Kent wrote:
Apparently the extra space was dumb luck. I didn't think it would
matter, since it's
part of the True-Text for the IF.
But, now I can't figure out what's going on. It keeps failing on the
Filename, when
I wasn't changing anything, other than the bullet structure. But after
running the CTRL-A, F9
to update all of the fields, it keeps repositioning where the quotes
are being position (behind
the Macro reference". I also wasn't including the '.doc' but now
trying it to fix this latest issue...
I just wish this SOB would react consistently so I could address the
issues appropriately.
Part of it may be self-inflicted, since I'm using 2007, but saving it
as 97-2003 compliant, which
may be injecting other issues... Problem is that most of the readers
most likely still have 2003.
Also, I'm trying to use minimal macros / VBA coding, since the folks
that I'll be leaving this with
are not coders, and I don't want to be married to this long term....
Tomorrow's another day... Hoping I can fix this latest issue on a
fresh pot of coffee in the morning...
*Thanks for the advise.
Kent
On Aug 23, 3:26 am, Peter Jamieson
wrote:


...

read more »- Hide quoted text -

- Show quoted text -


Yeah, the folks that I'll be leaving this with manage multiple process
documents, and that's all they do. When I showed them what little I
have in there for the IF and drop-downs, they were somewhat concerned
about being able to understand it. Now they understand Network
technology (switches, routers, etc.), since they work in that
environment, so I wouldn't classify them as techno-phobes, but
software logic is not there thing.

What's disappointing is that even the features that were provided
INCLUDETEXT, referencing other variables, etc. seem to have only been
given a cursory test at the top level. It doesn't appear to have been
tested with any expectation of nesting functions within other
functions. And it seems that the HYPERLINK function has some other
undocumented behaviors, especially when trying to use it resolve the
path and filename from another variable.

I'd be happy to have this thread forwarded to MS, but I'm not sure
what to do about it. Nor, do I have much time to deal with it, since
I'm a couple of weeks behind schedule now that I've been playing with
these other options. Let me know if there's something else I should do
along this line.

Regards,
Kent