![]() |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]()
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 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 |
Thread Tools | |
Display Modes | |
|
![]() |
||||
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 |
![]() |
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 |
![]() |
Agog | Word VBA | 4 | 05-03-2018 05:30 AM |
![]() |
heyjim | Drawing and Graphics | 1 | 08-07-2015 05:23 PM |