Duplication Macro & Macro crashing Word

B

boredofcities

I used this forum to get help with some Visual Basic before because I'm an
absolute novice. I was given advice on a couple of Macros, one which
duplicates text from another form field and one that changes the colours of
cells based on a selection from a dropdown form field, but I am now having
some issues with both of them.

The duplication macro:

Sub CopyText()

With ActiveDocument
.FormFields("Bookmark1").Result = .FormFields("Bookmark2").Result
End With

End Sub

The problem I have with the macro above is when the text is copied from
"Bookmark2" into "Bookmark1", I would like to be able to amend the text in
"Bookmark1" after it has been copied. Is there anyway to disable the macro
once it has copied the text across?


My second macro:

Sub DropDownCode()

Dim celTarget As Cell

With Selection.FormFields(1)
Set celTarget = .Range.Cells(1)
ActiveDocument.Unprotect
Select Case .DropDown.Value
Case "1"
celTarget.Shading.BackgroundPatternColor = RGB(153, 51, 0)
Case "2"
celTarget.Shading.BackgroundPatternColor = RGB(181, 18, 27)
Case "3"
celTarget.Shading.BackgroundPatternColor = RGB(196, 160, 6)
Case "4"
celTarget.Shading.BackgroundPatternColor = RGB(58, 76, 1)
Case "5"
celTarget.Range.Rows(1).Delete
End Select
ActiveDocument.Protect wdAllowOnlyFormFields, True
End With

End Sub

This macro changes a cells colour based on a selection from a dropdown
formfield. The macro does what its supposed to but when you move the cursor
into another formfield, it crashes Word. Is there a problem with the macro or
the method of moving into other formfields that crashes Word?

I am using Word 2007. The form is protected for filling in forms. If there
is any other info you need please ask.

Thanks for you time and anticipated help.

Matt.
 

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