Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 174
  • Last Modified:

I need help with a Word Macro

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
mvp1985
Asked:
mvp1985
  • 6
  • 2
1 Solution
 
Phillip BurtonCommented:
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
 
mvp1985Author Commented:
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
 
Phillip BurtonCommented:
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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
mvp1985Author Commented:
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
 
mvp1985Author Commented:
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
 
mvp1985Author Commented:
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
 
mlmccCommented:
If this is answered elsewhere, how about including the link to the question with the answer?

mlmcc
0
 
mvp1985Author Commented:
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

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

  • 6
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now