?
Solved

Word Makro

Posted on 2014-11-24
4
Medium Priority
?
133 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 1500 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction Authors who set out to write any sort of lengthy piece for online submission—be it a long question or comment on a technical form, an article, or a substantial blog entry—often find it useful to work up a draft in an editor other t…
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
Learn how to make your own table of contents in Microsoft Word using paragraph styles and the automatic table of contents tool. We'll be using the paragraph styles in Word’s Home toolbar to help you create a table of contents. Type out your initial …
Suggested Courses

762 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