Forms and Pictures and Macros

N

Ned

Oh wise people! Please take pity on this poor corpro-slave!

While I can record a macro, I am apparently genetically unable to figure out
how to write one.

I really hope someone can help me. Please.

Below is the macro I have now. As you can see, depending on the keybord
shortcut it will delete one or two pictures in a document. This is a form
though so in order for this to work, I need a macro to unprotect the
document, type in a password (password should be "formform"), delete the
photo (or photos) and then reprotect the document with the password again.

Can someone give me the correct macro (suitable for cutting and pasting)?
Thank you.

If needed, I can tell you that I am using Office 97.

Thank you very much.

Ned.

Sub homeinsurance()
'
' home Macro
' Macro recorded 2009/02/17 by Ned Smith
'
ActiveDocument.Shapes("Picture 10").Select
Selection.Cut
End Sub
Sub auto()
'
' auto Macro
' Macro recorded 2009/02/17 by Ned Smith
Selection.Cut
ActiveDocument.Shapes("Picture 7").Select
Selection.Cut
End Sub
 
G

Graham Mayor

I don't have Word97 to check, but if indeed it is shape7 and shape10 that
you want to remove then the following should do what you ask

Sub DeleteShapes()
Dim i As Integer
Dim bProtected As Boolean
Dim sPassword As String
sPassword = "formform"
With ActiveDocument
'Unprotect the file
If .ProtectionType <> wdNoProtection Then
bProtected = True
.Unprotect Password:=sPassword
End If
'*******************************
For i = .Shapes.Count To 1 Step -1
If i = 7 Or i = 10 Then
.Shapes(i).Delete
End If
Next i
'********************************
'Reprotect the document.
If bProtected = True Then
.Protect _
Type:=wdAllowOnlyFormFields, _
NoReset:=True, Password:=sPassword
End If
End With
End Sub

However the sections above and below the starred section is the
unlocking/locking routine. The rest you can modify as required for your
documents

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - 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