Old Version Problem or Strange Dialog?

Started by twright3, June 20, 2025, 10:17:28 AM

Previous topic - Next topic

twright3

I'm trying to audit thousands of pictures inserted as links in dozens Word files. I have a 20-year-old version of WinBatch and Microsoft Office 2007. (I'm retired and don't pay for updates without a good reason.)
Setting up: In word, I have clicked on the little down arrow next to the quick access icons at the very top of Word, selected "More Commands" in the menu and in the resulting dialog added "Edit Links to Files". In Word documents, when using Insert Picture, after selecting the file I have clicked on the down arrow part of the Insert button and selected Link to File. This saves space in the Word document and allows the picture to be updated without editing the word file.
The problem: Now I want to make a list of the linked files in each Word document. In Word with a document open that has picture links, I can click on the quick access link icon (3 chain links) and Word puts up a links dialog.
This dialog seem inaccessible to WinBatch. Notice there is no title bar. RoboScrp can't identify any of the controls. I can't even access the OK or Cancel buttons, much less the list control or the full file path than shows in the dialog when I select an item from the list. I've been reduced to using MouseMove and MouseClick. MouseMove has to be relative to Word because the Links dialog's existence isn't recognized. If the dialog is moved, the MouseMove X and Y are off. Worse yet, I have to use Microsoft's Snip tool and its OCR to get the data I want. In the dialog's font, capital i and lower case L are identical resulting in OCR errors. The Snip tool makes othe OCR errors as well.
Question: Is the latest version of WinBatch able to interact with Word's Links dialog and access the controls?
Thank you,
Tom
ps. I have an annotated screenshot of Word and the Links dialog but don't see how to add a picture to a post.

td

I don't have a copy of Office 2007, but the insert link dialog in Word 2021 has the title "Insert Hyperlink." WinBatch 2025B has no problem finding that dialog.

Sorry, I cannot be of more help.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

twright3

"Insert Hyperlink" is not the dialog I'm having trouble with. You need to have a word file with a picture already inserted via a link. You need to turn on access to the link editing dialog by adding the links icon to the the quick access icons as described in my original post. Then you need to click on that icon to see the dialog in question.
See this screenshot: https://photos.app.goo.gl/umuqKi6628wp11JQA
A is how you turn on the Edit Links icon.
B is what you see once it's turned on; click it.
C looks like the dialog title but isn't; the dialog won't appear unless the document already has at least one picture inserted via a link.
D is a list box control I can't access.
E is the text I want to copy but can't access.
F is one of the buttons I can't access.
Tom

spl

You might consider posting a sample Word doc with inserted image. Might be possible for ObjectOpen("Word.Application") to do your bidding. I checked my archives and ran across a 2005 Word_Exportpics.wbt script I wrote. That version of WB 20 years old.
Stan - formerly stanl [ex-Pundit]

JTaylor

While it doesn't answer your question regarding menu/link access in Word and if you just want the links, one option might be to export document into HTML and extract from there???   Assuming it doesn't just download the pictures locally doing that.

Just thought I would throw that out there.  I rarely do any type of Office Automation so will leave that to others to respond further.

Jim

twright3

spl,
Thanks for the suggestion, but I feel posting a Word document with links wouldn't be particularly helpful. Google says I can post a word document to Facebook, but it would have links to pictures that aren't there. Also, anyone who wants such a document for experimentation can create one themselves in a minute or two by opening a new document, clicking the Insert tab, clicking on Picture, entering any picture file path in the resulting dialog, clicking the down arrow by Insert and selecting Link to a File from the short menu.
JTaylor,
I previously thought this was a great idea, and I tried this prior to wrestling with difficulties of the Links dialog. I'm working with over 200 documents and, with the different formatting in the different documents, the resulting HTML documents were wildly inconsistent and, in spite of extensive efforts to ferrent them out, some of the links could not be found.
It's amazing to me that 2007 Word's Links dialog (not to be confused with the dialog for inserting a link as it was in the first Reply) is so wildly non-standard in spite of its innocent appearance. I don't have access to the current version of word to see if this is still true.
Tom

spl

As I drop out of this thread, I'll just say Jim and I were trying to be helpful. Based on your last post, I am now assuming you have Word documents with links to external image files (local drive; network drive; URL). As Jim suggested, and  I referenced, saving the doc file to html is a way to accomplish an edit, and can be scripted with about 7 lines of 2004B WB code. One issue was that in the earlier Word (Office 2007) images were often linked as inserts into a Word table which could cause confusion.
file = "pathtofile.doc"
newfile = "pathtofile.html"
App = ObjectOpen("Word.Application")
Docs = App.Documents
Doc = Docs.Open(file)
wdFormatFilteredHTML = 10
Doc.SaveAs(newfile,wdFormatFilteredHTML)
Doc.Close()
App.Quit()

But I know with newer Office (probably 2013 =>) Word has a hyperlinks property and processing them from either a local file or domain is trivial.
Stan - formerly stanl [ex-Pundit]

twright3

I appreciate the efforts responders made to help with this problem. My goal of finding out if the obscure Links pseudo-dialog has been updated remains unanswered. This was probably created decades ago and is probably one of the least used dialogs in Word, so I guess not. If I had my life to live over again...
- the original post would have contained the pointer to a screenshot of the dialog
- I would have noted HTML files left out perhaps 4% of the links for unexplained reasons
- I would have pointed out the Word files are encrypted, making using HTML undesirable
I'm sorry I didn't paint as complete a picture as I should have.
I'll finish by saying I resolved the OCR issue with a script that found the "missing" files that are really misspellings. Then I did a little research on fuzzy string compares. I wrote a script that compared the alleged file name with all the file names in the directory to find the best fit to use to correct the OCR error. I see the script posting section of this forum hasn't been used in several years so I'll post here the compare code (the smaller the result, the closer the fit):

#DefineFunction Levenshtein(s1, s2)
   len1 = StrLen(s1)
   len2 = StrLen(s2)
   d = ArrDimension(len1+1, len2+1)
   for i=0 to len1
      d[i,0] = i
   endfor
   for j=0 to len2
      d[0,j] = j
   endfor
   for i=1 to len1
      for j=1 to len2
         if (StrCmp(StrSub(s1, i, 1),StrSub(s2, j, 1))==0)
            cost = 0
         else
            cost = 1
         endif
         d[i,j] = min(d[i-1,j]+1, d[i,j-1]+1, d[i-1,j-1]+cost)
      endfor
   endfor
   return d[len1,len2];
#EndFunction

td

Nothing quite like an algorithm from a Soviet mathematician.

Thanks for the script.

Also, as far as I can tell, your strange dialog no longer exists in Word.
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

spl

Interesting segue. While I maintain searching/outputting links or shapes from a Word document can be a trivial COM exercise (I wrote one for both regular, password protected and AES encrypted docx which included a hash table lookup for the mso shape enum), just wondering how the algorithm to search from best match for file string in a folder would compare against a Regex pattern match.
Stan - formerly stanl [ex-Pundit]

td

The Levenshtein distance is an algorithm that measures the number of character edits required to change one string to another*. I like it because it is a simple and clever algorithm. Its main weakness is that it doesn't detect transpositions, i.e., it would score a transposition as 2 edits of difference instead of 1. It is the type of thing a software developer keeps in the back pocket, in case he/she/they encounter a use case. It is still a part of information science, but I am sure the Tech Bro's AI will/has replace it in some or many applications.

You could write a regex expression to do exactly what the Levenshtein distance algorithm does. It would be an interesting exercise.

* That is a close paraphrase of something I read somewhere. I would add an acknowledgment if I could remember where I read it.

 
"No one who sees a peregrine falcon fly can ever forget the beauty and thrill of that flight."
  - Dr. Tom Cade

SMF spam blocked by CleanTalk