Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-24-2015, 10:33 AM
bill98502 bill98502 is offline Identifying name of inserted photos in document Windows 7 64bit Identifying name of inserted photos in document Office 2010 64bit
Novice
Identifying name of inserted photos in document
 
Join Date: Feb 2015
Posts: 1
bill98502 is on a distinguished road
Default Identifying name of inserted photos in document

I insert a lot of photos into my documents. Much later I sometimes need to identify a photo, that is, the actual image name. Is there a way to see the name of the photo after it is in a document?



Thanks
Bill
Reply With Quote
  #2  
Old 03-13-2015, 08:15 AM
BruceM BruceM is offline Identifying name of inserted photos in document Windows 7 64bit Identifying name of inserted photos in document Office 2010 32bit
Advanced Beginner
 
Join Date: Feb 2015
Posts: 41
BruceM is on a distinguished road
Default

Edit: I posted the main part of this response (below the line of asterisks), but then realized it is for text links, not linked pictures. I located the following link. The first response (from Cindy Meister) shows a solution for linked images:
https://social.msdn.microsoft.com/Fo...?forum=worddev

The following is my original posting, in case it has some relevance:

***************************
I don't think you can do that with embedded images, but it should be possible with linked images. There is also an option to link and embed, but I'm not sure quite how that works.

A while ago I came up with the following to list hyperlinks to a csv (text) file. I came up with some of it on my own, but I borrowed from other sources as well. Usually I attribute the code in the procedure header, but in this case I did not. My apologies to the author(s) -- I have no intent to claim their work as my own.

The Sub identifies hyperlinks both in the body of the document and in text boxes. I converted commas to the pipe character in the hyperlink address because it would otherwise treat the comma as a delimiter in the csv file. If you are using a txt file that won't be necessary, but I used csv so I could view in Excel.

I believe you need to create the destination (csv) file before you begin.

This code is in an Add-In. I call the sub from any open document, and it processes all files in the same folder.

Another option, I believe, is to convert to Word 2003 format and toggle the field codes, which will show you the path and file name. Word 2007+ seems to have dropped the ball here, or maybe it is by design, but if so the purpose is unclear.

Code:
 
Public Sub ExportToTextFile()
'
' ExportToTextFile Macro
  Dim strOutput As String     ' Output string
  Dim strDoc    As String     ' Abbreviated name of document containing hyperlink
  Dim strAD     As String     ' Active document name
  Dim strA      As String     ' Hyperlink address
  Dim strLoc    As String     ' Folder in which file is located
  Dim strPath   As String     ' Folder containing documents to be processed
  Dim strFile   As String
  Dim strLink   As String
  Dim myDoc     As Document
  Dim h         As Hyperlink
  Dim aShape    As Shape
  Dim intProt   As Integer    ' Protection type of current document
  Dim n         As Integer
 
On Error GoTo ExportToTextFile_Error
  strPath = _
    ActiveDocument.Path
  strLoc = _
    Mid(strPath, InStrRev(strPath, "\") + 1)
  strPath = _
    strPath & "\"
  n = _
    FreeFile()
 
' Close all open documents before beginning
  Documents.Close SaveChanges:=wdPromptToSaveChanges
  Open "C:\MyFolder\Links.csv" For Append As #n
  Print #n, strLoc
' Set the directory and type of file to process
  strFile = _
    Dir$(strPath & "*.doc")
  While strFile <> ""
  ' Open document
    Set myDoc = _
      Documents.Open(strPath & strFile)
    strAD = _
      ActiveDocument.Name
    intProt = _
      myDoc.ProtectionType
    If intProt <> -1 Then
        myDoc.Unprotect
    End If
 
  ' Find hyperlinks in text boxes
    For Each aShape In ActiveDocument.Shapes
      If aShape.TextFrame.HasText Then
          For Each h In aShape.TextFrame.TextRange.Hyperlinks
            strA = _
              h.Address
            strA = _
              Replace(strA, ",", "|")
            If Len(strA) > 0 Then
                strDoc = _
                  Left(strAD, InStr(strAD, "(") - 2)
                strOutput = _
                  "Text box, " & strDoc & ", " & strA & ", " & h.Range.Information(wdActiveEndPageNumber)
                Print #n, strOutput
            End If
          Next h
      End If
    Next aShape
  ' Find hyperlinks in document body
    For Each h In ActiveDocument.Hyperlinks
      strA = _
        h.Address
      strA = _
        Replace(strA, ",", "|")
      If Len(strA) > 0 Then
          strDoc = _
            Left(strAD, InStr(strAD, "(") - 2)
          strOutput = _
            "Document, " & strDoc & ", " & strA & ", " & h.Range.Information(wdActiveEndPageNumber)
          Print #n, strOutput
      End If
    Next h
  ' Close the document; save changes in case Word thinks it's necessary
    With myDoc
      .Protect (intProt)
      .Close SaveChanges:=wdSaveChanges
    End With
  ' Next file in folder
    strFile = _
      Dir$()
  Wend
  Close #n
ProcExit:
  Exit Sub
ExportToTextFile_Error:
  MsgBox "Error " & Err.Number & " (" & Err.Description & ") " & _
         "in ExportToTextFile" & "   " & h.Address & "; " & h.Range.Information(wdActiveEndPageNumber)
  Resume ProcExit
End Sub
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Identifying name of inserted photos in document Unable to get cursor past inserted shape in Word document slknova Word 6 11-09-2021 09:02 AM
Identifying name of inserted photos in document Identifying Postcodes. Chayes Word VBA 13 09-21-2013 06:29 AM
Identifying name of inserted photos in document Identifying Irregular Characters d4okeefe Word VBA 2 05-09-2013 03:14 PM
Identifying name of inserted photos in document How to create a document with photos to share online? Tutorials? frascati Word 3 11-18-2012 11:37 PM
Identifying the Dynamic Connector cyberbhai Misc 0 12-14-2005 03:55 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:37 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