Gaute Rønningen
asked on
Microsoft, Office Word, 2007, macro developement, adding input fields to a protected document
Hi experts,
I have a client that wants some templates for his company. They need to be protected from writing so I made dot-templates with Forms where you fill in what you need into grey input boxes.
The problem is that in a particular template. I need to be able to add more if needed.
Shown below - [] marks an input field, <> marks a regular field.
Case nr. <AutoNumberLgl Field>
[Title]
[Text]
In charge: [Name]
Deadline: [01.01.1970]
At the moment I have a macro at the Exit of the Deadline input field, but it doesn't want to add text to the document since it's been protected.
Any ideas how to do this or how to get around the problem?
Regards,
eX.
I have a client that wants some templates for his company. They need to be protected from writing so I made dot-templates with Forms where you fill in what you need into grey input boxes.
The problem is that in a particular template. I need to be able to add more if needed.
Shown below - [] marks an input field, <> marks a regular field.
Case nr. <AutoNumberLgl Field>
[Title]
[Text]
In charge: [Name]
Deadline: [01.01.1970]
At the moment I have a macro at the Exit of the Deadline input field, but it doesn't want to add text to the document since it's been protected.
Any ideas how to do this or how to get around the problem?
Regards,
eX.
ASKER
Tried adding:
Application.ActiveDocument .Unprotect "1"
at the beginning and:
Application.ActiveDocument .Protect wdAllowOnlyFormFields, , "1"
at the end, but all it does is show it for 1sec, then it disappears.
Application.ActiveDocument
at the beginning and:
Application.ActiveDocument
at the end, but all it does is show it for 1sec, then it disappears.
Can you supply the code, (document preferably) since if it shows the new fields for 1 sec there is something specific happening to revert back.
Chris
Chris
ASKER
ASKER
Think it's the protecting that reverts the document to it's original setting, because all text that was added/changed is also getting reverted.
Been away, will get back to it shortly
Chris
Chris
I am seeing the data to be in a table, i'm struggling to coe with he features in word 2007, (moved around) so may be wrong but.
I cannot see that in Sub Nysak you actually insert any fields though you do insert text and yes it disappears at the end of the sub.
Since the data seems to be in a table I wonder if that is a factor.
Chris
I cannot see that in Sub Nysak you actually insert any fields though you do insert text and yes it disappears at the end of the sub.
Since the data seems to be in a table I wonder if that is a factor.
Chris
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Thank you. I'm glad this worked for you.
JOrzech
MS Word MVP
JOrzech
MS Word MVP
1. Unprotect th document as part of the macro, add the fields then reprotect.
2. Insert a new section in the document ensure the existing fields are in a protected section and ensure also the 'extra' section is outside the zone then adfding fields to the excluded section is 'easy'.
Chris