Hello!
I could really use help with macro for inserting template.
I have a Main word macro file, with 2 front pages and a third page as a template. The document is password protected so the end user can only fill in the yellow marked areas, when they have filled in the 2 front pages and the third template page, and need to insert another 4 page exactly as page no 3. they press short command "Alt + N" as in new page.
the macro then should insert the new page from the template word file. and put it last, first unlocking the word file, then inserting, then putting the password back on.
This works fine as long as you are only active with the cursor in the yellow marked areas or at the end of the document. but when you for example ar in the header, or footer. the macro fails and stops when the word file is unprotected. wich is not good.
Could anyone help me?
I need it to always abort the current command, jump to last page in document, then unprotect the document, insert the template, and protect the document again. enabling the user to continuing adding information.
Pardon my english.
The code i use now is as follows.
Thanks in advance for any help!Sub NCCMallSimpel() ' ' NCCMallSimpel Makro ' Make new page ' ActiveDocument.Unprotect Password:="1111" Selection.EndKey Unit:=wdStory Selection.InsertBreak Type:=wdPageBreak Dim myDocPath As Selection Selection.InsertFile FileName:="Tabellmall Standard.docm", Range:="", ConfirmConversions:=False, Link:=False, Attachment:=False Selection.EndKey Unit:=wdStory Selection.TypeBackspace Selection.EndKey Unit:=wdStory ActiveDocument.Protect Password:="1111", NoReset:=False, Type:= _ wdAllowOnlyComments, UseIRM:=False, EnforceStyleLock:=False End Sub
Bookmarks