Change embedded Excel links in Word from Access??

S

sbowman

I have a module that opens up a Word doc and updates fields based on
the selected record in Access. The Word doc also has 10 embedded Excel
linked objects but they are linked to a template. I need Access to
automatically update the links with the Excel file that corresponds to
the selected record. Here's my code:

Dim shpLinked as Object
Dim intcounter1 as integer

intcounter1 = 1
For Each shpLinked In .ActiveDocument.InlineShapes
With shpLinked
If .OLEFormat.ProgId = "Excel.sheet.8" Then
With .LinkFormat
.SourceFullName = somefilepath
.AutoUpdate = True
DoEvents
End With

End If
End With
intcounter1 = intcounter1 + 1
If intcounter1 = 11 Then Exit For
Next shpLinked

This code only works for the first embedded object, it doesn't touch
the rest. It looks like it loops through the first embedded object 10
times instead of going to the next object in the Word doc. I tried For
Each shpLinked In .ActiveDocument.InlineShapes(intcounter1) but got an
error. HELP!!

Thanks!
Shelley
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top