rcampbell
08-27-2011, 03:46 PM
Hello VBA Community. I am using Word 2007 and am attempting to automate several forms that I use fairly often. My goal is to have all of the form fields throughout the document auto-populate upon entering variable information on a "top page." Each macro is supposed to run upon exiting a form field.
I am receiving the following error when the macro attempts to run.
"Run Time Error 4605: This method or property is not available because the document is a protected document."
A sample of the code that was recorded is as follows:
Sub CopyStreetAddress()
'
' CopyStreetAddress Macro
'
'
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=83
Selection.MoveUp Unit:=wdLine, Count:=20
Selection.MoveDown Unit:=wdLine, Count:=8
Selection.MoveLeft Unit:=wdCharacter, Count:=11
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.PasteAndFormat (wdPasteDefault)
ActiveWindow.ActivePane.SmallScroll Down:=36
Selection.MoveDown Unit:=wdLine, Count:=11
Selection.MoveUp Unit:=wdLine, Count:=4
Selection.MoveLeft Unit:=wdCharacter, Count:=19
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.PasteAndFormat (wdPasteDefault)
Selection.TypeText Text:=" "
ActiveWindow.ActivePane.SmallScroll Down:=1
Selection.MoveDown Unit:=wdLine, Count:=252
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.MoveRight Unit:=wdCharacter, Count:=51
Selection.PasteAndFormat (wdPasteDefault)
Selection.TypeText Text:=" "
Selection.MoveDown Unit:=wdLine, Count:=125
Selection.MoveUp Unit:=wdLine, Count:=10
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=38
Selection.PasteAndFormat (wdPasteDefault)
Selection.TypeText Text:=" "
Selection.MoveDown Unit:=wdLine, Count:=205
Selection.MoveUp Unit:=wdLine, Count:=9
Selection.MoveLeft Unit:=wdCharacter, Count:=14
Selection.PasteAndFormat (wdPasteDefault)
Selection.TypeText Text:=" "
Selection.MoveDown Unit:=wdLine, Count:=53
Selection.MoveUp Unit:=wdLine, Count:=11
Selection.MoveRight Unit:=wdCharacter, Count:=45
Selection.PasteAndFormat (wdPasteDefault)
Selection.TypeText Text:=" "
Selection.MoveDown Unit:=wdLine, Count:=110
ActiveWindow.ActivePane.SmallScroll Down:=56
Selection.MoveUp Unit:=wdLine, Count:=195
End Sub
As I have virtually no experience in VBA, I'd appreciate the simplest solution/response to my problem.
Many thanks!
I am receiving the following error when the macro attempts to run.
"Run Time Error 4605: This method or property is not available because the document is a protected document."
A sample of the code that was recorded is as follows:
Sub CopyStreetAddress()
'
' CopyStreetAddress Macro
'
'
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=83
Selection.MoveUp Unit:=wdLine, Count:=20
Selection.MoveDown Unit:=wdLine, Count:=8
Selection.MoveLeft Unit:=wdCharacter, Count:=11
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.PasteAndFormat (wdPasteDefault)
ActiveWindow.ActivePane.SmallScroll Down:=36
Selection.MoveDown Unit:=wdLine, Count:=11
Selection.MoveUp Unit:=wdLine, Count:=4
Selection.MoveLeft Unit:=wdCharacter, Count:=19
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.PasteAndFormat (wdPasteDefault)
Selection.TypeText Text:=" "
ActiveWindow.ActivePane.SmallScroll Down:=1
Selection.MoveDown Unit:=wdLine, Count:=252
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.MoveRight Unit:=wdCharacter, Count:=51
Selection.PasteAndFormat (wdPasteDefault)
Selection.TypeText Text:=" "
Selection.MoveDown Unit:=wdLine, Count:=125
Selection.MoveUp Unit:=wdLine, Count:=10
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.MoveLeft Unit:=wdCharacter, Count:=38
Selection.PasteAndFormat (wdPasteDefault)
Selection.TypeText Text:=" "
Selection.MoveDown Unit:=wdLine, Count:=205
Selection.MoveUp Unit:=wdLine, Count:=9
Selection.MoveLeft Unit:=wdCharacter, Count:=14
Selection.PasteAndFormat (wdPasteDefault)
Selection.TypeText Text:=" "
Selection.MoveDown Unit:=wdLine, Count:=53
Selection.MoveUp Unit:=wdLine, Count:=11
Selection.MoveRight Unit:=wdCharacter, Count:=45
Selection.PasteAndFormat (wdPasteDefault)
Selection.TypeText Text:=" "
Selection.MoveDown Unit:=wdLine, Count:=110
ActiveWindow.ActivePane.SmallScroll Down:=56
Selection.MoveUp Unit:=wdLine, Count:=195
End Sub
As I have virtually no experience in VBA, I'd appreciate the simplest solution/response to my problem.
Many thanks!