Word2007: Automate "Change Picture"

A

alainr

I find the feature "Change Picture" very convenient to update pictures in a
document to the lastest revision on file. I like the fact that this feature
keeps all the parameters of the shape object intact and only updates (or
changes) the picture.

I am looking for way to use this feature as-is in VBA.

I tried to record the steps word performs by recording a macro when invoking
this feature, however the macro does not capture the process.

Does anyone have any idea how to use that feature as-is from VBA?
 
G

Greg Maxey

I have heard that. Also heard the one about what happens to 100 sailors
after they surface... :)
 
G

Greg Maxey

Yikes. That sailor joke wasn't supposed to appear here.

alainr,

You can do that using the ExcuteMso method of the commandbars object:

Sub ScratchMacro()
If Selection.Type = wdSelectionInlineShape Or wdSelectionShape Then
CommandBars.ExecuteMso ("PictureChange")
End If
End Sub

You can find the appropriate MsoID by looking at Word Options>Customize>All
Commands then mousing over the the command of interest.
 
A

alainr

Thanks for this tip Greg.

Unfortunately this only takes me half-way.
I programmatically know which picture I want to replace and therefore would
like to feed this automatically into the dialog box. For example I found the
following information relevant the Office 2003 system:

"Built-in Dialog Box Argument Lists"
http://msdn.microsoft.com/en-us/library/aa211930(office.11).aspx

But I can't find the wdWordDialog constant corresponding to "Change
Picture". For example the dialog box that pops-up when invoking "Change
Picture" appears identical to the "Insert Picture" dialog, however when
attempting to use the wdDialogInsertPicture, the picuture is indeed replaced,
but the shape properties are not retained in the process, hence the need for
the perculiarities of the "Change Picture" feature.

I would assume there might be a "wdDialogPictureChange" wdWordDialog
constant build-in to Office 2007, but so far have been unable to find the
exact name.
 

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