Delete Inline Shape Problem

S

spunkymuffmonkey

Hi.

I have a command button within my document that present users with a userform.

When this document is printed I have intercepted the print command with the
following so that the command button is not printed:

Sub FilePrint()

With ActiveDocument
If .ProtectionType <> wdNoProtection Then
.Unprotect Password:="Gatekeeper1"
End If
End With

ActiveDocument.InlineShapes(1).Delete
ActiveDocument.FormFields("Text13").Delete
Dialogs(wdDialogFilePrint).Show
ActiveDocument.Undo 3

ActiveDocument.Protect NoReset:=True, Password:="Gatekeeper1",
Type:=wdAllowOnlyFormFields

My problem is that when the deleted inlineshape is 'undone', it is
reinserted with an errant 1 on the end of the object name, for example
'CommandButton1' becomes 'CommandButton11', and I cannot find a way to
programatically change it back.

Any suggestions or help would be great.

Many thanks
 
D

DaveLett

Hi,
If all else fails, you could close the document and not save changes:

ActiveDocument.Close SaveChanges:=wdDoNotSaveChanges

If you need the document open, you can reopen it.

HTH,
Dave
 

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