Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-26-2023, 04:33 AM
ChrisGreaves ChrisGreaves is offline Word Fields and Relative Paths to External Files - IncludePicture field problems Windows 10 Word Fields and Relative Paths to External Files - IncludePicture field problems Office 97-2003
Novice
Word Fields and Relative Paths to External Files - IncludePicture field problems
 
Join Date: Nov 2022
Location: Bonavista, Newfoundland
Posts: 22
ChrisGreaves is on a distinguished road
Default Word Fields and Relative Paths to External Files - IncludePicture field problems

I am trying to implement a technique proposed by Macropod in the topic Word Fields and Relative Paths to External Files.
I can see the result of the {Filename \P} and have tried both the "/../" and the "\\.." methods. As far as I can see both methods work for the end-user (me!) until i try yo access the {IncludePicture} field in VBA.




Four macros provide access to images, here is one:-
Code:
Sub ShowImageToUser()
        Dim fld As Field
    If Selection.Fields.Count = 0 Then
'        MsgBox "EditImage - You need to select an IncludePicture field!"
        Set fld = ActiveDocument.Fields(1)
    Else
        Set fld = Selection.Fields(1)
    End If
        Dim strFullname As String
        strFullname = fld.Code.Text
        Call UW.strsplitat(strFullname, """")
        strFullname = UW.strsplitat(strFullname, """")
        ActiveDocument.FollowHyperlink Address:="file:" & strFullname
 End Sub


My macro fails on the last line, and the debug window shows this (attached image)


Thanks for any help
Chris




Attached Images
File Type: png ShowImageToUser.png (27.8 KB, 21 views)
Reply With Quote
  #2  
Old 04-26-2023, 04:02 PM
Guessed's Avatar
Guessed Guessed is offline Word Fields and Relative Paths to External Files - IncludePicture field problems Windows 10 Word Fields and Relative Paths to External Files - IncludePicture field problems Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,969
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Following a hyperlink to a path which included the other field code like Filename \p is also problematic.

If the path doesn't contain spaces then the "quotes" you are expecting probably won't be in the field code so strsplitat method won't separate out the piece of information you wanted.
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 05-27-2023, 07:55 AM
ChrisGreaves ChrisGreaves is offline Word Fields and Relative Paths to External Files - IncludePicture field problems Windows 10 Word Fields and Relative Paths to External Files - IncludePicture field problems Office 97-2003
Novice
Word Fields and Relative Paths to External Files - IncludePicture field problems
 
Join Date: Nov 2022
Location: Bonavista, Newfoundland
Posts: 22
ChrisGreaves is on a distinguished road
Default

Quote:
Originally Posted by Guessed View Post
If the path doesn't contain spaces then the "quotes" you are expecting probably won't be in the field code so strsplitat method won't separate out the piece of information you wanted.

Guessed, I do apologize for my late reply. I have made several essays with the {filename \p}, starting with the problem raised in my application WbWrd (web page compiler), and then whittling it down to the simplest problem I could reproduce.


Attached is a file Greaves.ZIP, with a test.doc that morphs on update - which is why the original arrives in a zip file.


On two different essays using the <F9> function key to update a document causes mini-havoc in my Word2003 system. The latest example is documented here:-


Stage1.jpg shows my document. The heading1 uses the keyboard {} and is not a field. After the four {IncludePicture} fields I have the {filename\p} field just for documentation. In this image the two personal images appear twice, which is how it should be.


Stage2.jpg shows the fieldcodes in use. I have a macro All which toggles all settings in Tools Options View, hence "All" or Nothing. I believe that this image shows that the second pair of IncludePicture field codes are installed correctly. I have been known to make mistakes ...


Stage3.jpg shows that I have used Select All and the <F9> key to update all fields. All four images show as they should; so far, so good. This update-all-fields occurs immediately prior to compiling a web page from a document, so in this essay i am manually updating fields which is normally done by VBA code.


Stage4.jpg reveals what is in my document when I toggle All switches in Tools, Options, View. The fieldcodes {filename \p} in the second pair have been removed or executed, and the fieldcode {filename \p} is removed.


Over the past three months I have been trying different ways of using {filename \p}, beginning by assuming that the fieldcode remained in place and then discovering a week later that it had disappeared!


At this point I have two basic questions:-
(1) Am I creating the compound fieldcodes correctly?
(2) Is the {filename \p} supposed to be transient? Or should it remain in place, because I understand the purpose of the {filename \p} to be useful in a mobile document and image set.


Thanks for any advice, and again, I do apologize for being sluggish in scratching my head in trying to resolving this issue.
Chris
Attached Images
File Type: png Stage_1.png (231.9 KB, 9 views)
File Type: png Stage_2.png (42.9 KB, 9 views)
File Type: png Stage_3.png (233.3 KB, 9 views)
File Type: png Stage_4.png (42.7 KB, 9 views)
Attached Files
File Type: zip Greaves.zip (707.6 KB, 1 views)
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
INCLUDEPICTURE for external URLs has stopped working in new Windows word versions (pixel tracking) mrgoos Word 8 09-24-2021 01:09 PM
@Macropod Macro VBA LINK Fields Relative Paste Special as Image from Excel word bug ggll Word 0 09-18-2021 11:48 PM
Word Fields and Relative Paths to External Files - IncludePicture field problems Word Fields and Relative Paths to External Files macropod Word 0 04-08-2018 05:06 PM
Word Fields and Relative Paths to External Files - IncludePicture field problems Copy IncludePicture field code VEA Word 1 06-21-2016 07:01 PM
Has the problem with relative paths been resolved in Word 2010? Aston Word 1 10-24-2012 11:38 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:10 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft