View Single Post
  #9   Report Post  
Posted to microsoft.public.word.docmanagement
TishyMouse TishyMouse is offline
external usenet poster
 
Posts: 7
Default Using a conditional parameter within the LINK field

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


.