Hi everyone,
I've used a macro for a while now that dumps a snapshot of an excel range into word. An extra few lines adds the original location (spreadsheet file, sheet and range) to the dumped image (In the web alternative text field) so the info can be traced back.
Works great once but since I don't know how the numbering on objects works my code only adds this extra bit to the LAST (numerically) image. For example...fill a blank word document with pictures and everything is great. If I go back, delete number 2 (for example) and reinsert a new one in it's place this extra info does not get added to the newest picture.
Here's the code:
I realize this is code running from Excel but the code is all specific to Word.
Any help on adding the soruce info to the last image pasted would be greatly appreciated.
Kindest regards and a million thanks in advance,
kkjensen
P.S. This is only a snippet of the real code. I can include more if needed. For this to work the Word library needs to be added in the excel VBA editor.
I've used a macro for a while now that dumps a snapshot of an excel range into word. An extra few lines adds the original location (spreadsheet file, sheet and range) to the dumped image (In the web alternative text field) so the info can be traced back.
Works great once but since I don't know how the numbering on objects works my code only adds this extra bit to the LAST (numerically) image. For example...fill a blank word document with pictures and everything is great. If I go back, delete number 2 (for example) and reinsert a new one in it's place this extra info does not get added to the newest picture.
Here's the code:
Code:
' Copy the range in Excel
Selection.CopyPicture Appearance:=xlScreen, _
Format:=xlPicture
'Past in Word
WDApp.Selection.Paste
'******ADD SOURCE INFORMATION ******************************
With WDDoc.InlineShapes(WDDoc.InlineShapes.Count)
.AlternativeText = Application.Substitute( _
Selection.Address(External:=True), _
"!" & Selection.Address, "")
End With
'**********************************************************
I realize this is code running from Excel but the code is all specific to Word.
Any help on adding the soruce info to the last image pasted would be greatly appreciated.
Kindest regards and a million thanks in advance,
kkjensen
P.S. This is only a snippet of the real code. I can include more if needed. For this to work the Word library needs to be added in the excel VBA editor.