View Single Post
  #10   Report Post  
Posted to microsoft.public.word.docmanagement
macropod[_2_] macropod[_2_] is offline
external usenet poster
 
Posts: 2,059
Default Using a conditional parameter within the LINK field

Hi TishyMouse,

Yes, it's true that the double quotes aren't *required* unless the filename or path has spaces. Using them as a matter of course is
good practice though and, in this case, guards against any changes in the way Word works treating the {DOCPROPERTY Region} field as
if it were not part of the file/path name string (this is more relevant to INCLUDETEXT and INCLUDEPICTURE fields since, as
previously discussed, you can't use a field variable in a LINK field). Do note that the lack of spaces in your filepath, filename
and sheet reference were not apparent from your post. Conversely, I should have had:
"\\\\domain.com\\mypath\\MyExcelFile.xls" MySheet!Name_US
or:
"\\\\domain.com\\mypath\\MyExcelFile.xls" "MySheet!Name_US"
and not:
"\\\\domain.com\\mypath\\MyExcelFile.xls MySheet!Name_US"


--
Cheers
macropod
[Microsoft MVP - Word]


"TishyMouse" wrote in message ...
Thanks for confirming that MP and saving my hair from more pulling out :-). I
guess I'll have to go back to the {IF} syntax (or perhaps investigate using a
macro to do a global search and replace).

By the way AFAIK the double quotes aren't necessary unless there is a space
in any of the parameter values. My first example {LINK Excel.Sheet.8
\\\\domain.com\\mypath\\MyExcelFile.xls MySheet!Name_UK \f 0 \p} works fine.

TM

"macropod" wrote:

Hi TishyMouse,

Unfortunately, the approach you're after won't work as any field within a LINK field gets converted to its result the first time
the
LINK field is updated. Consequently, you'll need to use IF tests coded along the lines of:
{IF{DOCPROPERTY Region}= "UK" {LINK Excel.Sheet.8 "\\\\domain.com\\mypath\\MyExcelFile.xls MySheet!Name_UK" \f 0 \p} {LINK
Excel.Sheet.8 "\\\\domain.com\\mypath\\MyExcelFile.xls MySheet!Name_US" \f 0 \p}}
or:
{IF{DOCPROPERTY Region}= "UK" {LINK Excel.Sheet.8 "\\\\domain.com\\mypath\\MyExcelFile.xls MySheet!Name_UK" \f 0 \p}}
{IF{DOCPROPERTY Region}= "US" {LINK Excel.Sheet.8 "\\\\domain.com\\mypath\\MyExcelFile.xls MySheet!Name_US" \f 0 \p}}

Note: The field brace pairs (ie '{ }') for the above example are created via Ctrl-F9 - you can't simply type them or copy & paste
them from this message. Note also the addition of the double quotes in the LINK fields - their omission may have had something to
do
with your field's failure.


--
Cheers
macropod
[Microsoft MVP - Word]


"TishyMouse" wrote in message ...
I have a Word document that includes links to a number of tables in an Excel
spreadsheet. The links are defined in terms of defined names in the
spreadsheet. I'd like to be able to link to different tables depending on the
value of a custom property in the Word document but I can't get this to work.

e.g. the following works OK:
{LINK Excel.Sheet.8 \\\\domain.com\\mypath\\MyExcelFile.xls MySheet!Name_UK
\f 0 \p}

but I'd like to use something like
{LINK Excel.Sheet.8 \\\\domain.com\\mypath\\MyExcelFile.xls
MySheet!Name_{DOCPROPERTY Region} \f 0 \p}

Where the names Name_UK, Name_US etc. are defined within the Excel sheet and
'Region' is a property of the Word document.

However it doesn't work at least with this syntax (I just get an 'Error! Not
a valid link' message). Does Word actually support this or does anyone know a
different way to implement this functionality? I realise one alternative
would be to have a number of nested {IF } statements for the different
regions but that will get very messy and hard to maintain.


TIA

TishyMouse


.