I have the following links to Excel in a word document:
[URL=http://s12.photobucket.com/user/hypersonik/media/linkdump_zpsy9hghggl.png.html][IMG]http://i12.photobucket.com/albums/a212/hypersonik/linkdump_zpsy9hghggl.png[/IMG][/URL]
The issue is that when changes are made the document version on both the excel sheet referenced and the word document change.
As such I will need to update the link path.
I would like to do this with a VBA macro and here is what I have so far:
Sub Replace_Link()
Dim iShp As InlineShape
Dim exWb As Excel.Workbook
For Each iShp In ActiveDocument.InlineShapes
With ActiveDocument
Set exWb = objExcel.Workbooks.Open(.Path & "" & Replace$(.Name, ".docm", ".xlsm"))
End With
With iShp
If Not .OLEFormat Is Nothing Then
If Split(.OLEFormat.ClassType)(0) = "Excel" Then
.LinkFormat.SourcePath = exWb
End If
End If
End With
Next
End Sub
I am getting a 'User defined type not defined' for the 'Dim exWb As Excel.Workbook'. I'm also pretty sure that I'll need more code to include the 'Worksheet' type links that cannot be updated with the 'inlineShape' command.
Is this something anyone can help with? TIA
Recent Questions...
ما را در سایت Recent Questions دنبال میکنید
برچسب:
نویسنده: استخدام کار
بازدید: 275
تاريخ: پنجشنبه
3 تير
1395 ساعت: 21:51