Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge a protected document

Status
Not open for further replies.

cramd2

Programmer
Jun 10, 2005
51
US
System: Windows XP PRo
Software: Office 2003
Issue: I've created a new document with several merge fields. A help desk person will now take the document and merge this directly to the printer. When the operator merges the document, if she mistakenly types on the document or hits the enter key and then merges, the documents merged will be wrong. I need to prevent the document from being changed/edited once the document has been approved for merging. I've tested the "protect the document" option - this will protect the document from any edits, but then I don't have the choice to "merge" the document. So basically I'm asking, is there a way to protect the document, but still allow a user to have merge options??
 
try making the doc read only. It should still allow the merge.

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Hi cramd2,

Making the doc read only, as suggested by misscrf, probably won't help, since you can still change the read-only document before merging. All that making the file read-only achieves is to prevent the changes being saved in the original.

What you could do, though, is to protect the document and provide a user interface for the user to work through to trigger the mailmerge. This could be coded to acquire any inputs, then unprotect the document, run the merge, and re-protect the document upon completion.

Cheers
 
Cheers,
Read only would not be an option since they could mistakenly type on the document and then complete merge. With testing, I realized even in read only, they could make a change on the document and the merge would complete with the changes. Now, your thought about the user interface, that is what I was considering. So basically, I would:
1) create the document
2) protect it
3) run a macro that removes the "protection", then displays a user input form for merging? This would replace the merge toolbar options - correct??
I understand what your saying, I just need some help getting started? I'm familiar with VBA coding - I'm looking for any examples or links to help get me started on this.
cramd2
 
Hi cramd2,

Yes, that's the basic idea, though I haven't ever needed to do that kind of thing myself. However, depending on what you need it might be no more complicated that providing the user with a button to click on to run the macro. I'd also change the execution order, to:
1) create the document
2) protect it
3) run a macro that:
A) displays a user input form for merging;
B) removes the "protection";
C) performs the merge; and
D) re-protects the document.
Alternatively, you could use an autorun macro that simply runs the merge with little or no user input as soon as the document is opened, and closes when finished. Then, you possibly wouldn't even need to worry about protection issues.

Cheers
 
Hi Macropod (alias Cheers) - it was late last night when I responded....
I like the button idea, but I'm stuck on "C" - I'm not sure how to invoke the merge dialog box that allows the operator to choose which records to merge. Any thoughts?
cramd2
 
Macropod,
One more question, my code is working just as needed except for adding the protection back on the document. I can't get the protection on because of the merged document, (step 3D). I think I need to remove the merge source before I can add the document protection back on - I'm not sure how to remove the merge source in code. Any thoughts??
cramd2
 
I could be totally off base, because you two seem to be much more intelligent than me, but I wonder something.

I looks like you merge to a new document. Now the focus is on the new document. I wonder if you can't re-protect the document, because you need to make it the active document or window again.

Just a thought, as I sit out here in left field. lol.

misscrf

It is never too late to become what you could have been ~ George Eliot
 
misscrf -
I am merging directly to the printer, so my macro is performed on the original document. The document is opened by the operator, (in it's protected form), I have a button that runs the macro, it is unknowned to the operator when the macro runs that it becomes unprotected at the time of the merge, but before the macro completes, I have to reprotect the document. This is where I'm stuck, with the datasource & merged fields, I can't get the document protected. Within my code, I have to remove the datasource or the merged fields - I'm not sure??
Keep talking this through with me, maybe I'll get it yet!
cramd2
 
misscrf & macropod.....
I have it - macro button working perfectly! Now the user can no longer mistakenly edit the now protected document and can still complete the merge.
OH the joys of recording macros!!
cramd2
 
congrats!

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top