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
.
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