Code: Select all
#Requires AutoHotkey v2.1-a
#SingleInstance Force
xrelPath := ".\media\MonaLisa.jpg"
xFullPath := A_Scriptdir . "\media\Monalisa.jpg"
; Open Word Document
oWord := ComObject("Word.Application")
oWord.Visible := true
oWord.Activate
WinWaitActive "ahk_class OpusApp",,2
oDoc := oWord.Documents.Add()
Sleep 500
; Upload Picture to Word with fullpath
xNextPar := 0
oDoc.Paragraphs.item(++xNextPar).range.InsertParagraphAfter()
oAfbeelding := oDoc.Paragraphs.item(xNextPar).range.InlineShapes.AddPicture(xFullPath)
; Upload Picture to Word with relative path
oDoc.Paragraphs.item(++xNextPar).range.InsertParagraphAfter()
oAfbeelding := oDoc.Paragraphs.item(xNextPar).range.InlineShapes.AddPicture(xRelPath)
Now in this case it is not a big issue because the picture can be stored in the document. But when you use shortcutes to documents your document is no longer portable when you use the fullpath.
Anybody an idea?