How do we format a picture object as a "macro enabled template obj

R

Rogerph100

I maintain a set of Word 2003 templates that have a data gathering form that
runs off an "autonew" macro and then populates bookmarks with the content of
the text boxes then cleans up the bookmarks in VBA.

In the header block there is a picture object (our corporate logo) that is
there while data is being entered on the form, but when the macro runs and
clears the bookmarks the logo disappears. It did not happen when we tested
the templates a few years ago.

Now a colleague in a support company found she could convert the picture
object into a Microsoft macro enabled word template object by right clicking
on the picture and after that reformat it no longer disappears when the macro
is run.

I have a full install of Office Professional 2003 (I selected "run all from
my computer" for Word and for shared components) but cannot find out how to
acquire the option to convert the picture object into this macro enabled
object thing.

Can anyone help please?
 
J

Jay Freedman

Hi Roger,

You're mixing terminology like apples and oranges, with a sprinkling of
voodoo.

The term "macro enabled Word template" is specific to the new formats used
by Word 2007, and the concept doesn't exist in versions before that (unless
you install the Word 2007 Compatibility Pack, which I doubt you've done). It
refers to a file format, not to anything having to do with objects or
graphics.

The operation of bookmarks and macros has not changed in Word 2003 from that
in 2002 or earlier versions, so the change must be somewhere in your
template. I suspect one of two things may be happening: Either a bookmark
has been wrongly defined to include the logo, so the logo is removed when
the bookmark is cleared; or the code of the macro has been altered in some
way. There's no way to diagnose the exact cause without seeing the template
and its bookmarks and code.

One simple thing you can do for yourself: In Tools > Options > View, check
the box for Bookmarks. That makes the beginning and end of each bookmark
visible as a pair of thick, gray square brackets. Do you see brackets
surrounding the logo, with or without other text? If so, you can use the
GoTo button in the Insert > Bookmark dialog to figure out which bookmark it
is. I can't tell you whether such as bookmark is supposed to be there, but
it would be a clue.

--
Regards,
Jay Freedman
Microsoft Word MVP
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.
 
R

Rogerph100

Jay,

You will understand I cannot send a corporate template to the group - may I
send two files to your email address? One which misbehaves and loses it's
logo and one which doesn't? The one which doesn't misbehave has our logo
stored on the template as a "Microsoft Word macro enabled template object" in
Word 2003". It was converted to that by someone who does not have Word 2007
on the machine.

Thanks and regards,
Roger
 
J

Jay Freedman

Roger,

You may send the templates (please zip them). It may be a day or two until I can
look at them because we're traveling this week.

Can you please explain where you see the phrase "Microsoft Word macro enabled
template object" in connection with the logo? Is it in a dialog in Word, or is
it just something you were told?
 
R

Rogerph100

Jay,

The words "Microsoft Office Word macro enabled template object" appear in
the dialogue box that appears when you right click on the logo in the header.
This happens in the documents where my colleague converted the picture
objects by right clicking the logo and selecting Picture object convert
(instead of open) she gets "Microsoft Office Word macro enabled template
object" as well as word document or word picture.

On my machine if I right click on a picture object the dialogue shows
Picture object with the triangle to indicate further menu choices which are
then reveales as word document or word picture.

Files and screen shot on the way within the next few minutes....

Thanks,
Roger
 
R

Rogerph100

I have now received the following from Jay and can confirm after testing that
this is the solution we were seeking....Thank you Jay!

Hello Roger,

The mystery is solved. The cause of the disappearing logo was an interaction
between the code in the userform and a side-effect of the way the logo was
inserted into the template. Allow me to explain...

After the userform code inserts the user's data into the documents, it
executes a loop that deletes all the bookmarks and their contents. Normally
that wouldn't affect the logo. However, the logo evidently was inserted by
drag-and-drop from another program rather than by Insert > Picture > From
File, and a side-effect of that is that Word creates a bookmark -- in this
case, one named OLE_LINK1. When the code deletes the bookmarks, that one
goes too, and the logo with it.

The fact that the logo doesn't disappear from the "good" template doesn't
have anything to do with the type of object it is, but rather with the fact
that the conversion silently removed the OLE_LINK1 bookmark at the same
time. So the code doesn't have any bookmark there to delete, and the logo
stays in place.

The quickest way to fix the "bad" template is to open it for editing, go to
Insert > Bookmark, select OLE_LINK1 from the list, and click the Delete
button.

A better solution is to rewrite the userform code so it doesn't have to
delete any bookmarks. The code looked to me as though it was written by
looking at the results of the macro recorder, which isn't very good. Instead
of selecting each bookmark and "typing" the text into it, it's more
efficient (and less error-prone) to simply set the bookmark's .Range.Text
property equal to the desired string. Because of the "typing replaces
selection" behavior of Word, that also deletes the bookmark at the same
time. I've made that sort of change in the attached modified template.

I hope this serves you well. Please don't hesitate to ask any questions that
occur to you.

Regards,
Jay Freedman
Microsoft Word MVP
 

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