Solved

I need help with a Word Macro

Posted on 2014-11-23
9
168 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
Plug and play, no additional software required!

The ATEN UE3310 USB3.1 Gen1 Extender Cable allows users to extend the distance between the computer and USB devices up to 10 m (33 ft). The UE3310 is a high-quality, cost-effective solution for professional environments such as hospitals, factories and business facilities.

 

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 101

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 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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

I was prompted to write this article after the recent World-Wide Ransomware outbreak. For years now, System Administrators around the world have used the excuse of "Waiting a Bit" before applying Security Patch Updates. This type of reasoning to me …
Outlook for dependable use in a very small business   This article is about using the Outlook application (part of Microsoft Office) in a very small business, or for homeowners where dependability and reliability are critical requirements. This …
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 …
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.

617 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