Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-11-2022, 07:25 PM
zanodor zanodor is offline Insert Image Reference in Each Deprecated Picture's Place in Multiple Documents Windows 10 Insert Image Reference in Each Deprecated Picture's Place in Multiple Documents Office 2016
Novice
Insert Image Reference in Each Deprecated Picture's Place in Multiple Documents
 
Join Date: Jun 2022
Posts: 17
zanodor is on a distinguished road
Default Insert Image Reference in Each Deprecated Picture's Place in Multiple Documents

Hello all,

I am running a script that does all kinds of things (mostly find and replace to account for new syntax and styles) that ultimately saves my docx files in a folder into plain txt files which will no longer have a valid reference to all the images (jpg's, png's and gif's alas, but I could fix those by making them all jpg's to make things easy) but with the following two macros I would call after one another, I could point to the new files in a different (markdown) program (the references to images is
Code:
![[image.jpg]]
.
I couldn't make it work, alas. Probably a pro could merge the two macros into one as well.

Code:
Sub ReferenceMyImages()
    On Error Resume Next
    Dim pic As Word.InlineShapes
    Dim PicPath As String
For Each pic In ActiveDocument.InlineShapes
    With pic
    PicPath = Selection.ShapeRange(1).LinkFormat.SourceFullName
    PicPath = Selection.InlineShapes(1).LinkFormat.SourceFullName
    Selection.Collapse wdCollapseEnd
    Selection.TypeText vbCr & "<img src=" & Chr(34) & PicPath & Chr(34) & ">" & "Image Found Here"
    Selection.Collapse wdCollapseEnd
    End With
Next
End Sub
Code:
Sub ImageHere()
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find
        .Text = "Image Found Here"
        .Replacement.Text = "![[image^&.jpg]]"
        .Forward = True
        .Wrap = wdFindContinue
        .Format = False
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub
With the second one I totally lost it, as I couldn't face trying to figure out how to put the brackets and all the code for WHAT I WANT: [each image in ActiveDocument matching the folder with the FileName (appended with) + files (in folder name) I got saved out by saving the docs to html beforehand.
So one filename is "Arad" and if that doc had any pics embedded in it, the corresponding folder's name will be "Arad_files". Each with different number of images (with different extensions, to boot) in those folders, if any.

I am now 85 percent done with the a migration project involving 14000 lexical entries mostly to do with religion history, archeoastronomy, astrotheology and etymology.
I was postponing migrating to a different platform for a long time. Working with hefty documents and having to rely on proximity/range search trying to find topics and bits of data previously catered to was no longer feasable. I had to find a more productive way and environment (Zettelkasten which works with markdown files and can be used a bit like a database).

If anybody is willing to help or willing to at least ask me to clarify even more what I want (it's 4.25 am where I live and want to call it a...whatever...), that would be much appreciated.

Regards,

Zan

Last edited by zanodor; 07-12-2022 at 09:58 AM. Reason: To wrap text up as code
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
VBA Insert Image(logo) into header for multiple Word Docs Axis Word VBA 4 02-09-2022 10:34 PM
Insert Image Reference in Each Deprecated Picture's Place in Multiple Documents Changing footer image in Multiple word documents killabyte Word VBA 2 09-23-2020 05:49 AM
How to place an image placeholder that scales the image to the full frame size in a template Cube Word 5 07-05-2020 08:27 AM
Insert Image Reference in Each Deprecated Picture's Place in Multiple Documents Adding Title Image to Multiple Documents. Agog Word VBA 4 05-03-2018 05:30 AM
Insert Image Reference in Each Deprecated Picture's Place in Multiple Documents Replace footer image in multiple Word documents heyjim Drawing and Graphics 1 08-07-2015 05:23 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:46 AM.


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