Solved

Word Makro

Posted on 2014-11-24
4
124 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

The Selection object is designed for user interaction. It has a Range property, so it can be used in most places that a Range object can. Recorded macros must use the Selection because they are simply copying what the user is doing. A Range prope…
Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
This video shows and describes the main difference between both orientations in Microsoft Word. Viewers will understand when to use each orientation and how to get the most out of them.
Learn how to create and modify your own paragraph styles in Microsoft Word. This can be helpful when wanting to make consistently referenced styles throughout a document or template.

919 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now