includepicture and path to picture

T

Tom Stian

Hi all!

Hope you can help me with this question. I've been browsing the web for an
answer to my problem, but all the solutions I find are based on that the path
to a picture is static. Mine, however is not.

The background:
In a CRM/ERP program, you can link a picture to a product. This is stored in
a table (SQL) as the path to the picture (example:
\\server\Picture\Product\Table\Pic1.jpg), and not the picture itself. This
means that I cannot create an INCLUDEPICTURE using a static path to the
pictures, as the path is part of the field I have to retrieve from the table.

I've come this far, but I can't seem to get to the finish line:
{ INCLUDEPICTURE "{ Report.Get("g_Prod", "Picture") }" \d \* MERGEFORMAT }

Where { Report.Get("g_Prod", "Picture") } retrieves the path to the picture.
I don't think this is an integrated code in Word, but an addon created by the
CRM/ERP company.

This creates the red cross picture, and when i Alt+F9 it, it gives me the
following:
{ INCLUDEPICTURE "\\server\Picture\Product\Table\Pic1.jpg" \d \* MERGEFORMAT }

I then have to edit the field, put two additional \\ in front of \\server
and press OK, and the picture works.

I've also tried:
{ INCLUDEPICTURE "\\{ Report.Get("g_Prod", "Picture") }" \d \* MERGEFORMAT }

This gives me the following value:
{ INCLUDEPICTURE "\\\\server\Picture\Product\Table\Pic1.jpg" \d \*
MERGEFORMAT }

But no picture. Still have to edit the field, but can now press only OK to
make it leap into action.

My question is therefore.. Is there a code I can use to replace singel \
with \\ in the mergefield, or is there any way I can change the path to the
picture without doing it manually? Maybe use a different mergefield to change
normal path to \\\\server\\picture\\and_so_on

Example:
{ INCLUDEPICTURE "{=REPLACE({ Report.Get("g_Prod", "Picture") }, "\", "\\"}"
\d \* MERGEFORMAT }

All help will be appreciated!

Regards,

Escariot
 
M

macropod

Hi Tom,

Can you change the path separators from \ to / in the source file? That would probably fix the problem. An alternative would be to
replace each path separator with \\ or / via a macro after merging.

Also, you can get rid of the '\* MERGEFORMAT' switch - AFAIK it does nothing useful for INCLUDEPICTURE fields.
 
E

Escariot

Hi, and thank you for the swift reply.

I am not able to change anything in the SQL-table. If I do, then the
OLE/Active-X object in the report generator (Visual FoxPro 9) will not print
the picture, and the picture is not viewable from product information.

Sadly, I'm not familiar with VB macros, so I have no clue as to how to write
such a scipt :eek:)

Are there no mergefield or other code that can convert \\server\and_so_on to
\\\\server\\and_so_on (or /server/and_so_on for that matter)?

Cheers
Tom

macropod said:
Hi Tom,

Can you change the path separators from \ to / in the source file? That would probably fix the problem. An alternative would be to
replace each path separator with \\ or / via a macro after merging.

Also, you can get rid of the '\* MERGEFORMAT' switch - AFAIK it does nothing useful for INCLUDEPICTURE fields.

--
Cheers
macropod
[MVP - Microsoft Word]


Tom Stian said:
Hi all!

Hope you can help me with this question. I've been browsing the web for an
answer to my problem, but all the solutions I find are based on that the path
to a picture is static. Mine, however is not.

The background:
In a CRM/ERP program, you can link a picture to a product. This is stored in
a table (SQL) as the path to the picture (example:
\\server\Picture\Product\Table\Pic1.jpg), and not the picture itself. This
means that I cannot create an INCLUDEPICTURE using a static path to the
pictures, as the path is part of the field I have to retrieve from the table.

I've come this far, but I can't seem to get to the finish line:
{ INCLUDEPICTURE "{ Report.Get("g_Prod", "Picture") }" \d \* MERGEFORMAT }

Where { Report.Get("g_Prod", "Picture") } retrieves the path to the picture.
I don't think this is an integrated code in Word, but an addon created by the
CRM/ERP company.

This creates the red cross picture, and when i Alt+F9 it, it gives me the
following:
{ INCLUDEPICTURE "\\server\Picture\Product\Table\Pic1.jpg" \d \* MERGEFORMAT }

I then have to edit the field, put two additional \\ in front of \\server
and press OK, and the picture works.

I've also tried:
{ INCLUDEPICTURE "\\{ Report.Get("g_Prod", "Picture") }" \d \* MERGEFORMAT }

This gives me the following value:
{ INCLUDEPICTURE "\\\\server\Picture\Product\Table\Pic1.jpg" \d \*
MERGEFORMAT }

But no picture. Still have to edit the field, but can now press only OK to
make it leap into action.

My question is therefore.. Is there a code I can use to replace singel \
with \\ in the mergefield, or is there any way I can change the path to the
picture without doing it manually? Maybe use a different mergefield to change
normal path to \\\\server\\picture\\and_so_on

Example:
{ INCLUDEPICTURE "{=REPLACE({ Report.Get("g_Prod", "Picture") }, "\", "\\"}"
\d \* MERGEFORMAT }

All help will be appreciated!

Regards,

Escariot
 
T

Tom Stian

Hi macropod, and thanks for the swift reply!

It is not possible to change the field in the SQL-table, as this will
corrupt the picture when using it as an OLE/Active-X object in the integrated
report generator (MS Visual FoxPro 9), and when viewing the picture from the
product module in the program itself.

Sadly, I'm not familiar with creating macros, so it does not seem like an
option to me :eek:)

Is there no way, using a different mergefield or switch or code to convert
\\server\and_so_on\ to \\\\server\\and_so_on\\ (or /server/and_so_on/ for
that matter)?

Cheers

Tom

macropod said:
Hi Tom,

Can you change the path separators from \ to / in the source file? That would probably fix the problem. An alternative would be to
replace each path separator with \\ or / via a macro after merging.

Also, you can get rid of the '\* MERGEFORMAT' switch - AFAIK it does nothing useful for INCLUDEPICTURE fields.

--
Cheers
macropod
[MVP - Microsoft Word]


Tom Stian said:
Hi all!

Hope you can help me with this question. I've been browsing the web for an
answer to my problem, but all the solutions I find are based on that the path
to a picture is static. Mine, however is not.

The background:
In a CRM/ERP program, you can link a picture to a product. This is stored in
a table (SQL) as the path to the picture (example:
\\server\Picture\Product\Table\Pic1.jpg), and not the picture itself. This
means that I cannot create an INCLUDEPICTURE using a static path to the
pictures, as the path is part of the field I have to retrieve from the table.

I've come this far, but I can't seem to get to the finish line:
{ INCLUDEPICTURE "{ Report.Get("g_Prod", "Picture") }" \d \* MERGEFORMAT }

Where { Report.Get("g_Prod", "Picture") } retrieves the path to the picture.
I don't think this is an integrated code in Word, but an addon created by the
CRM/ERP company.

This creates the red cross picture, and when i Alt+F9 it, it gives me the
following:
{ INCLUDEPICTURE "\\server\Picture\Product\Table\Pic1.jpg" \d \* MERGEFORMAT }

I then have to edit the field, put two additional \\ in front of \\server
and press OK, and the picture works.

I've also tried:
{ INCLUDEPICTURE "\\{ Report.Get("g_Prod", "Picture") }" \d \* MERGEFORMAT }

This gives me the following value:
{ INCLUDEPICTURE "\\\\server\Picture\Product\Table\Pic1.jpg" \d \*
MERGEFORMAT }

But no picture. Still have to edit the field, but can now press only OK to
make it leap into action.

My question is therefore.. Is there a code I can use to replace singel \
with \\ in the mergefield, or is there any way I can change the path to the
picture without doing it manually? Maybe use a different mergefield to change
normal path to \\\\server\\picture\\and_so_on

Example:
{ INCLUDEPICTURE "{=REPLACE({ Report.Get("g_Prod", "Picture") }, "\", "\\"}"
\d \* MERGEFORMAT }

All help will be appreciated!

Regards,

Escariot
 
P

Peter Jamieson

If it is possible to use a REPLACE function in FoxPro's dialect of SQL then
you may be able to do this by setting up the data source using Word VBA's
opendatasource call (i.e. some VBA still required). However, I don't have a
copy of FoxPro up and running here so cannot test/explore.

--
Peter Jamieson
http://tips.pjmsn.me.uk

Tom Stian said:
Hi macropod, and thanks for the swift reply!

It is not possible to change the field in the SQL-table, as this will
corrupt the picture when using it as an OLE/Active-X object in the
integrated
report generator (MS Visual FoxPro 9), and when viewing the picture from
the
product module in the program itself.

Sadly, I'm not familiar with creating macros, so it does not seem like an
option to me :eek:)

Is there no way, using a different mergefield or switch or code to convert
\\server\and_so_on\ to \\\\server\\and_so_on\\ (or /server/and_so_on/ for
that matter)?

Cheers

Tom

macropod said:
Hi Tom,

Can you change the path separators from \ to / in the source file? That
would probably fix the problem. An alternative would be to
replace each path separator with \\ or / via a macro after merging.

Also, you can get rid of the '\* MERGEFORMAT' switch - AFAIK it does
nothing useful for INCLUDEPICTURE fields.

--
Cheers
macropod
[MVP - Microsoft Word]


Tom Stian said:
Hi all!

Hope you can help me with this question. I've been browsing the web for
an
answer to my problem, but all the solutions I find are based on that
the path
to a picture is static. Mine, however is not.

The background:
In a CRM/ERP program, you can link a picture to a product. This is
stored in
a table (SQL) as the path to the picture (example:
\\server\Picture\Product\Table\Pic1.jpg), and not the picture itself.
This
means that I cannot create an INCLUDEPICTURE using a static path to the
pictures, as the path is part of the field I have to retrieve from the
table.

I've come this far, but I can't seem to get to the finish line:
{ INCLUDEPICTURE "{ Report.Get("g_Prod", "Picture") }" \d \*
MERGEFORMAT }

Where { Report.Get("g_Prod", "Picture") } retrieves the path to the
picture.
I don't think this is an integrated code in Word, but an addon created
by the
CRM/ERP company.

This creates the red cross picture, and when i Alt+F9 it, it gives me
the
following:
{ INCLUDEPICTURE "\\server\Picture\Product\Table\Pic1.jpg" \d \*
MERGEFORMAT }

I then have to edit the field, put two additional \\ in front of
\\server
and press OK, and the picture works.

I've also tried:
{ INCLUDEPICTURE "\\{ Report.Get("g_Prod", "Picture") }" \d \*
MERGEFORMAT }

This gives me the following value:
{ INCLUDEPICTURE "\\\\server\Picture\Product\Table\Pic1.jpg" \d \*
MERGEFORMAT }

But no picture. Still have to edit the field, but can now press only OK
to
make it leap into action.

My question is therefore.. Is there a code I can use to replace singel
\
with \\ in the mergefield, or is there any way I can change the path
to the
picture without doing it manually? Maybe use a different mergefield to
change
normal path to \\\\server\\picture\\and_so_on

Example:
{ INCLUDEPICTURE "{=REPLACE({ Report.Get("g_Prod", "Picture") }, "\",
"\\"}"
\d \* MERGEFORMAT }

All help will be appreciated!

Regards,

Escariot
 
M

macropod

Hi Tom,

On reflection, you can also delete the '\d' switch, reducing your INCLUDEPICTURE mergefield to:
{INCLUDEPICTURE "{ Report.Get("g_Prod", "Picture") }"}

Having deleted the '\d' switch, here are two ways to change the field code after the mailmerge:
.. WITHOUT a macro -
. Press Alt-F9
. Use Find/Replace, with '\' as the Find string and '/' as the Replace string
This will only work for you if the document has no other '\' characters.
.. WITHOUT a macro -
. Add the following code to, say, your Normal.dot template.

Sub FixMergePaths()
Dim oFld As Field
With ActiveDocument
For Each oFld In .Fields
If oFld.Type = wdFieldIncludePicture Then _
oFld.Code.Text = Replace(oFld.Code.Text, "/", "\")
Next
End With
End Sub

--
Cheers
macropod
[MVP - Microsoft Word]


Tom Stian said:
Hi macropod, and thanks for the swift reply!

It is not possible to change the field in the SQL-table, as this will
corrupt the picture when using it as an OLE/Active-X object in the integrated
report generator (MS Visual FoxPro 9), and when viewing the picture from the
product module in the program itself.

Sadly, I'm not familiar with creating macros, so it does not seem like an
option to me :eek:)

Is there no way, using a different mergefield or switch or code to convert
\\server\and_so_on\ to \\\\server\\and_so_on\\ (or /server/and_so_on/ for
that matter)?

Cheers

Tom

macropod said:
Hi Tom,

Can you change the path separators from \ to / in the source file? That would probably fix the problem. An alternative would be
to
replace each path separator with \\ or / via a macro after merging.

Also, you can get rid of the '\* MERGEFORMAT' switch - AFAIK it does nothing useful for INCLUDEPICTURE fields.

--
Cheers
macropod
[MVP - Microsoft Word]


Tom Stian said:
Hi all!

Hope you can help me with this question. I've been browsing the web for an
answer to my problem, but all the solutions I find are based on that the path
to a picture is static. Mine, however is not.

The background:
In a CRM/ERP program, you can link a picture to a product. This is stored in
a table (SQL) as the path to the picture (example:
\\server\Picture\Product\Table\Pic1.jpg), and not the picture itself. This
means that I cannot create an INCLUDEPICTURE using a static path to the
pictures, as the path is part of the field I have to retrieve from the table.

I've come this far, but I can't seem to get to the finish line:
{ INCLUDEPICTURE "{ Report.Get("g_Prod", "Picture") }" \d \* MERGEFORMAT }

Where { Report.Get("g_Prod", "Picture") } retrieves the path to the picture.
I don't think this is an integrated code in Word, but an addon created by the
CRM/ERP company.

This creates the red cross picture, and when i Alt+F9 it, it gives me the
following:
{ INCLUDEPICTURE "\\server\Picture\Product\Table\Pic1.jpg" \d \* MERGEFORMAT }

I then have to edit the field, put two additional \\ in front of \\server
and press OK, and the picture works.

I've also tried:
{ INCLUDEPICTURE "\\{ Report.Get("g_Prod", "Picture") }" \d \* MERGEFORMAT }

This gives me the following value:
{ INCLUDEPICTURE "\\\\server\Picture\Product\Table\Pic1.jpg" \d \*
MERGEFORMAT }

But no picture. Still have to edit the field, but can now press only OK to
make it leap into action.

My question is therefore.. Is there a code I can use to replace singel \
with \\ in the mergefield, or is there any way I can change the path to the
picture without doing it manually? Maybe use a different mergefield to change
normal path to \\\\server\\picture\\and_so_on

Example:
{ INCLUDEPICTURE "{=REPLACE({ Report.Get("g_Prod", "Picture") }, "\", "\\"}"
\d \* MERGEFORMAT }

All help will be appreciated!

Regards,

Escariot
 
M

macropod

Hi Tom,

Actually, a better rendition of the macro for your purposes might be:

Sub FixMergePaths()
Dim oFld As Field
With ActiveDocument
For Each oFld In .Fields
With oFld
If .Type = wdFieldIncludePicture Then
.Code.Text = Replace( .Code.Text, "/", "\")
.Update
.Unlink
End If
End With
Next
End With
End Sub

The modified code updates the field then unlinks the picture from the source file.

--
Cheers
macropod
[MVP - Microsoft Word]


macropod said:
Hi Tom,

On reflection, you can also delete the '\d' switch, reducing your INCLUDEPICTURE mergefield to:
{INCLUDEPICTURE "{ Report.Get("g_Prod", "Picture") }"}

Having deleted the '\d' switch, here are two ways to change the field code after the mailmerge:
. WITHOUT a macro -
. Press Alt-F9
. Use Find/Replace, with '\' as the Find string and '/' as the Replace string
This will only work for you if the document has no other '\' characters.
. WITHOUT a macro -
. Add the following code to, say, your Normal.dot template.

Sub FixMergePaths()
Dim oFld As Field
With ActiveDocument
For Each oFld In .Fields
If oFld.Type = wdFieldIncludePicture Then _
oFld.Code.Text = Replace(oFld.Code.Text, "/", "\")
Next
End With
End Sub

--
Cheers
macropod
[MVP - Microsoft Word]


Tom Stian said:
Hi macropod, and thanks for the swift reply!

It is not possible to change the field in the SQL-table, as this will
corrupt the picture when using it as an OLE/Active-X object in the integrated
report generator (MS Visual FoxPro 9), and when viewing the picture from the
product module in the program itself.

Sadly, I'm not familiar with creating macros, so it does not seem like an
option to me :eek:)

Is there no way, using a different mergefield or switch or code to convert
\\server\and_so_on\ to \\\\server\\and_so_on\\ (or /server/and_so_on/ for
that matter)?

Cheers

Tom

macropod said:
Hi Tom,

Can you change the path separators from \ to / in the source file? That would probably fix the problem. An alternative would be
to
replace each path separator with \\ or / via a macro after merging.

Also, you can get rid of the '\* MERGEFORMAT' switch - AFAIK it does nothing useful for INCLUDEPICTURE fields.

--
Cheers
macropod
[MVP - Microsoft Word]


Hi all!

Hope you can help me with this question. I've been browsing the web for an
answer to my problem, but all the solutions I find are based on that the path
to a picture is static. Mine, however is not.

The background:
In a CRM/ERP program, you can link a picture to a product. This is stored in
a table (SQL) as the path to the picture (example:
\\server\Picture\Product\Table\Pic1.jpg), and not the picture itself. This
means that I cannot create an INCLUDEPICTURE using a static path to the
pictures, as the path is part of the field I have to retrieve from the table.

I've come this far, but I can't seem to get to the finish line:
{ INCLUDEPICTURE "{ Report.Get("g_Prod", "Picture") }" \d \* MERGEFORMAT }

Where { Report.Get("g_Prod", "Picture") } retrieves the path to the picture.
I don't think this is an integrated code in Word, but an addon created by the
CRM/ERP company.

This creates the red cross picture, and when i Alt+F9 it, it gives me the
following:
{ INCLUDEPICTURE "\\server\Picture\Product\Table\Pic1.jpg" \d \* MERGEFORMAT }

I then have to edit the field, put two additional \\ in front of \\server
and press OK, and the picture works.

I've also tried:
{ INCLUDEPICTURE "\\{ Report.Get("g_Prod", "Picture") }" \d \* MERGEFORMAT }

This gives me the following value:
{ INCLUDEPICTURE "\\\\server\Picture\Product\Table\Pic1.jpg" \d \*
MERGEFORMAT }

But no picture. Still have to edit the field, but can now press only OK to
make it leap into action.

My question is therefore.. Is there a code I can use to replace singel \
with \\ in the mergefield, or is there any way I can change the path to the
picture without doing it manually? Maybe use a different mergefield to change
normal path to \\\\server\\picture\\and_so_on

Example:
{ INCLUDEPICTURE "{=REPLACE({ Report.Get("g_Prod", "Picture") }, "\", "\\"}"
\d \* MERGEFORMAT }

All help will be appreciated!

Regards,

Escariot
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top