PDA

View Full Version : Updating ActiveX Image Control when opening document



Chunk
11-15-2019, 12:08 PM
I have a weekly report that I produce for 6 different projects. Each report contains 50 or so graphs.
I am currently experimenting with a template that is using ActiveX Image Controls for each graph.

I have converted the graphs to jpgs and linked the control to the image, and am wondering if there
is a way to have the image control "refresh" the image when the document opens, or is there a way
to have some vba code perform the work?

Any help or direction is greatly appreciated.

Thanks in advance for your time.

Chunk

gmayor
11-15-2019, 10:49 PM
Why are you inserting activex controls? Surely simply inserting the images in-line as links would suffice? If you wish to constrain the sizes, put them in table cells of fixed width or frames.

If you are creating the charts in Excel, you could simply link to the charts themselves.

You can update the links with the following macro


Sub UpdateAllFields()
Dim oStory As Range
For Each oStory In ActiveDocument.StoryRanges
oStory.Fields.Update
If oStory.StoryType <> wdMainTextStory Then
While Not (oStory.NextStoryRange Is Nothing)
Set oStory = oStory.NextStoryRange
oStory.Fields.Update
Wend
End If
Next oStory
lbl_Exit:
Set oStory = Nothing
Exit Sub
End Sub