VBA to delete command button in MS-Word

I recently had some help by expert GrahamSkan to come up with the code below.   It works great but I need some assistance with a minor change.

*************
Sub CopyMe()
        Dim doc As Document
        Set doc = ActiveDocument
        doc.Shapes(1).Delete
        doc.SaveAs "C:\MyFolder\Test.doc"
End Sub
*************

The above code "deletes" a shape (i.e., rectangle) which calls the macro.

Now, instead of using a rectangular shape, I prefer to use a command button.

My question:   In MS-Word, what line(s) of code replaces the line "doc.Shapes(1).Delete" to remove "CommandButton1" instead?

EEH
ExpExchHelpAsked:
Who is Participating?

Improve company productivity with a Business Account.Sign Up

x
 
Rgonzo1971Connect With a Mentor Commented:
Hi,

Maybe

doc.InlineShapes(1).Delete

Open in new window

Regards
0
 
ExpExchHelpAuthor Commented:
Rgonzo1971:

Thanks for the prompt response.

I've replaced the shaped with a command button.

When clicking on the command button, however, nothing happens... except that the VBA editor is opened and the cursor flashed before line "Dim doc As Document".

Nothing is highlighted indicating a compile/syntax error though.

What's missing?

EEH
0
 
Rgonzo1971Commented:
Have you tried to close and reopen the file?
0
 
Rgonzo1971Commented:
Is the macro linked to the button?
0
 
ExpExchHelpAuthor Commented:
"That was easy!".    Yes, that's what it was... I had to close/reopen the document.

Thanks,
EEH
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.