Solved

I need help with a Word Macro

Posted on 2014-11-23
9
158 Views
Last Modified: 2014-12-01
I have created a word document with form protected text boxes. Now I also need to be able to insert auto text via a specified keyboard shortcut, which works fine when the document is not protected, but doesn't when it's protected, since it pastes in the last text box. So I think I need a macro that unprotects my sheet (no password), pastes the auto text, then protects it again. How do I do that?
0
Comment
Question by:mvp1985
  • 6
  • 2
9 Comments
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40460987
have a look at the two examples on http://msdn.microsoft.com/en-us/library/office/ff845016%28v=office.15%29.aspx

Between them, they should answer your question.
0
 

Author Comment

by:mvp1985
ID: 40462259
Let me refine my question: I need a makro that disables the protection, pastes something from autotext to The next page, and not within the form's text box. How do I get that to work? The protection and re-protect works fine now.
0
 
LVL 24

Expert Comment

by:Phillip Burton
ID: 40462327
By "The next page", do you mean the end of the document?

If so, then add this code before the pasting:

    Selection.EndKey Unit:=wdStory

Open in new window


If not, please clarify.
0
 

Author Comment

by:mvp1985
ID: 40462399
Now the entire makro doesn't produce an outcome anymore (nothing changes), but I do mean the end of the document.
Also: How do I assign the autotext "abc" instead of "department six"?

Thanks for your help.

So this is what I did:

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
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 

Author Comment

by:mvp1985
ID: 40462405
Oh, and by the way, I'm on apple, so I'm not sure if the "end key" doesn't work because of that
0
 

Accepted Solution

by:
mvp1985 earned 0 total points
ID: 40466913
Sub Macro3a()
    Dim aDoc As Document
    Dim strPassword As String
    strPassword = ""
    Set aDoc = ActiveDocument
    If aDoc.ProtectionType <> wdNoProtection Then
        aDoc.Unprotect strPassword
    End If
    Application.Templates(aDoc.AttachedTemplate.FullName). _
        BuildingBlockEntries("Schätzung 1").Insert Where:=aDoc.Bookmarks("\EndOfDoc").Range
    aDoc.Protect Type:=wdAllowOnlyFormFields, Password:=strPassword
 End Sub
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 40467084
If this is answered elsewhere, how about including the link to the question with the answer?

mlmcc
0
 

Author Comment

by:mvp1985
ID: 40468611
0
 

Author Closing Comment

by:mvp1985
ID: 40473303
reposted the quesiton with more specific details, since no one answered on this question. Other question was answered on spot, here no answer after I said that I use Word for Mac.
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this article we discuss how to recover the missing Outlook 2011 for Mac data like Emails and Contacts manually.
This article will shed light on the latest trends when it comes to your resume building needs. For far too long, the traditional CV format has monopolized the recruitment market.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

759 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

19 Experts available now in Live!

Get 1:1 Help Now