Solved

Word Makro

Posted on 2014-11-24
4
125 Views
Last Modified: 2014-11-24
I have created a word document with form protected text boxes and assigned a makro with a keyboard shortcut that unprotects and reprotects the sheet after it goes to the end of the document, and I enters a specified auto text.  However, the makro doesn't produce an outcome  (nothing changes) with some random text to be insterted.

So here my questions:

How do I assign the  autotext "abc" instead of the random text?
And what, if anything is wrong with the makro, since it doesn’t work? one reason I could come up with might be that a macbook does not have an EndKey. Does that matter?

So this is the current Makro:

Sub Macro3()
Set aDoc = ActiveDocument
If aDoc.ProtectionType <> wdNoProtection Then
 aDoc.Unprotect
    Selection.EndKey Unit:=wdStory
Set aDoc = ActiveDocument
If aDoc.ProtectionType <> wdNoProtection Then
 aDoc.Unprotect
 Selection.InsertBefore "department six"
 aDoc.Protect Type:=wdAllowOnlyRevisions, Password:=strPassword
End If
End Sub

thanks.
0
Comment
Question by:mvp1985
  • 3
4 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 40463131
It the document is not protected then the code will do nothing
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 40463143
If it is protected, you remove the protection, then you test it again. That test will be false and so nothing will be done.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 40463159
Try this instead:
Sub Macro3a()
    Dim aDoc As Document
    Dim strPassword As String
    
    strPassword = "Pass"
    Set aDoc = ActiveDocument
    If aDoc.ProtectionType <> wdNoProtection Then
        aDoc.Unprotect strPassword
    End If
    aDoc.Bookmarks("\EndOfDoc").Range.Text = "department six"
    aDoc.Protect Type:=wdAllowOnlyFormFields, Password:=strPassword
 End Sub

Open in new window

0
 

Author Closing Comment

by:mvp1985
ID: 40463911
Solved my first question, but not my second
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When creating Microsoft Word-based forms there may be a need to have a form field repeated throughout the whole document. For instance, with a company name, you may want this information repeated automatically throughout the document rather than man…
Introduction This tutorial provides instructions on how to properly format your Word document using the inbuilt tools provided. The benefits of using these tools means your documents are more accessible and easily portable to other applications an…
This video teaches the viewer how to align pictures around text while keeping the text properly aligned in the document.
This video walks the viewer through the process of creating an MLA formatted document, as well as a bibliography with citations.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question