| | |
Word Macros
Please support our Computer Science advertiser: Learn about neural networks and artificial intelligence.
![]() |
Can I find an answer here about a Word Macro issue? I am trying to apply a macro to a Protected Form document. The user will click on a button to "Add a new Activity" table, which is saved in annother file to be inserted using the macro. But when I apply the macro, this message appears: "Run-time error '4605' The object refers to a Protected document..." I found this code in some forum, but don't know how to configure to make my macro work...
Sub User_name()
' Macro by JanOSX
'
Dim nameStr As String, bName As String
Dim bookNum As Integer
nameStr = Environ("USERNAME")
bookNum = Selection.BookmarkID
ActiveDocument.Sections(2).ProtectedForForms = False
ActiveDocument.FormFields(bookNum).Select
Selection.TypeText (nameStr)
ActiveDocument.Sections(2).ProtectedForForms = True
End Sub
Anyone know how to program Word macros?
Sub User_name()
' Macro by JanOSX
'
Dim nameStr As String, bName As String
Dim bookNum As Integer
nameStr = Environ("USERNAME")
bookNum = Selection.BookmarkID
ActiveDocument.Sections(2).ProtectedForForms = False
ActiveDocument.FormFields(bookNum).Select
Selection.TypeText (nameStr)
ActiveDocument.Sections(2).ProtectedForForms = True
End Sub
Anyone know how to program Word macros?
Hi,
If you want to unprotect a document copy a selection from another document, paste in the unprotected form, and reprotect, use the below sub:
If you want to unprotect a document copy a selection from another document, paste in the unprotected form, and reprotect, use the below sub:
Sub CopyProt()
Windows("Doc2.doc").Activate
Selection.Copy
Windows("Doc1.doc").Activate
ActiveDocument.Protect wdNoProtection
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.PasteAndFormat (wdPasteDefault)
ActiveDocument.Protect wdAllowOnlyFormFields
End Sub Thank you, I will try this. If you need any help with design, I'll be around...
•
•
•
•
Hi,
If you want to unprotect a document copy a selection from another document, paste in the unprotected form, and reprotect, use the below sub:
Sub CopyProt() Windows("Doc2.doc").Activate Selection.Copy Windows("Doc1.doc").Activate ActiveDocument.Protect wdNoProtection Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.PasteAndFormat (wdPasteDefault) ActiveDocument.Protect wdAllowOnlyFormFields End Sub
![]() |
Similar Threads
- Help a newbie - Word Macros (Windows NT / 2000 / XP)
- "Macros Are Disabled" Error Message Win Word 2003 (Windows NT / 2000 / XP)
- Error Message in Word: Visual Basic Box 'Macros in this project are Disabled' (Windows NT / 2000 / XP)
- DDE Poke - Stay minimized (Visual Basic 4 / 5 / 6)
- PLease rate/review my resume (IT Professionals' Lounge)
- Need help with including C++ code in Word macro (C++)
- help with Word VBA macros (Windows NT / 2000 / XP)
- isdesign.ocx and mscomct2.ocx (Visual Basic 4 / 5 / 6)
- I need help using VBA for Word Macros (Windows NT / 2000 / XP)
Other Threads in the Computer Science Forum
- Previous Thread: Word datatype values
- Next Thread: Complexity of an algorithm
| Thread Tools | Search this Thread |
Tag cloud for Computer Science
ai algorithm algorithms assignment assignmenthelp assignments battery bigbrother binary bittorrent bletchleypark blogging bomb business clueless codebreaker compiler computer computerscience computertrackingsoftware connect conversion csc data dataanalysis dataintepretation development dfa dissertation dissertationtopic ebook employment energy extensions floatingpoint foreclosure foreclosuresoftware fuel geeks givemetehcodez government graphics hardware history homeowners homework homeworkassignment homeworkhelp humor ibm idea ideas internet iphone ipod jobs kindle laser laws lazy linkbait lsmeans mainframes marketing mining mobileapplication nano netbeans networking news os p2p parser piracy piratebay programming rasterizer research sam-being-cute sas science security simulation software spoonfeeding spying sql stephenfry student supercomputer supercomputing sweden technology tree turingtest two'scompliment uk virus warehouse ww2





