Solved

I need help with a Word Macro

Posted on 2014-11-23
9
166 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
[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
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 

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

Flexible connectivity for any environment

The KE6900 series can extend and deploy computers with high definition displays across multiple stations in a variety of applications that suit any environment. Expand computer use to stations across multiple rooms with dynamic access.

Question has a verified solution.

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

The advancement in technology has been a great source of betterment and empowerment for the human race, Nevertheless, this is not to say that technology doesn’t have any problems. We are bombarded with constant distractions, whether as an overload o…
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
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 …

738 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