Solved

Word Makro

Posted on 2014-11-24
4
120 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
Comment Utility
It the document is not protected then the code will do nothing
0
 
LVL 76

Expert Comment

by:GrahamSkan
Comment Utility
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
Comment Utility
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
Comment Utility
Solved my first question, but not my second
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
A few years ago I was very much a beginner at VBA, and that very much remains the case today.  I'll do my best to explain things as I go in the hope that other beginners can follow.  If you just want to check out a tool that creates a Select Case fu…
This video shows where to find the word count, how to display it, and what it breaks down to in Microsoft Word.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

743 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