Solved

I need help with a Word Macro

Posted on 2014-11-23
9
163 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 

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

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

In this article we have discussed about the OS X EI Capitan and how to fix Wi-Fi issue in OS X El Capitan. We have explained how to delete system level preferences and create a new Wi-Fi location to resolve Wi-Fi issue.
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…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

856 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