PDA

View Full Version : Solved: Printing clears fields in template



M-a-d-m-a-n
04-11-2005, 11:08 PM
This problem is probably more Windows-related than Word, but maybe anyone has a clue. Word2k automatically clears all filled-in fields in a template when you enable security. I bypassed this by creating my own button:
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True with the noreset-setting.

We also have a lot of code created to bypass the standard printing operation, to make sure the different templates are printed from the right tray with different printers. I also used the noreset-setting there, it's works fine. It disabled the security, processes the vba-code, prints the document and then enables the security again. But recently I encountered a few users with the following problem. When they print a template-file with the fields already filled-in (logically), the field are emptied. The fields are emptied before the security is enabled again, so it happens with the disabling of the security. I found out that the problem can be solved by deleting the users' profile ntuser.dat (we use Win2K).

Is this really the only solution to this, or does anyone have another solution for this??

Killian
04-12-2005, 01:04 AM
Just a guess... but it sounds like the users default print settings (which would be applied when the user opens Word, are intefering with what you want to do. This would make sense if deleting their profile solves the issue. I wonder if it might help to put your securtiy settings macro in the open event of the document.

M-a-d-m-a-n
04-12-2005, 02:08 AM
I use a centralised template to suppress the fileprint and fileprintdefault actions and replace them with my own. It's been a while, I don't remember if the problem also occurs when I use the same unprotect-action without the printing, or at what exact time the fields are emptied. I've had three users with this problem so far, but none at the moment (because we deleted the profile). I'll keep the topic open for a while, hopefully (...) I'll get another call soon...

Thanks so far.

MOS MASTER
04-12-2005, 11:10 AM
Hi,

Yes the resetting off formfields is a problem <=2000 and it has been resolved >2002. (The doing it manually part (Interface <> Code)
So with an upgrade you totaly loose this problem. :rofl:

Word 2000 has more field related issues and all are fixed with hotfixes form MS..are you up to date on you're Office updates?

Another option could also be that the Users Normal.dot template got corrupted and that could explain the trouble as well...

If it hapens again you might want to check the User's option and check if: Fast Save is on (This does generate a lot of problems in Word and corruptions)
Also you might want to check if Background printing is on in Word! If so (which is normal) you might want to uncheck it and try again. (If Word has more resources available to process you might get surprising results...that would tell you something about the resources on the computer also)

O that's right! Are you changing any of the formfield properties in you're code? (like name and stuff) This always resets a value in a formfield as well so...might want to check for stuff like that..

Enjoy! :thumb

M-a-d-m-a-n
04-14-2005, 02:37 AM
I just got a call from a user that has the problem. I'll try the following:

* Check where in the code the fields are emptied

* Re?nstall printers
* Delete normal.dot

* Install SP3

I'll let you know...

Update 1:
Ok, the news so far. The things I tried above, didn't help. When I remove my custom central template (for the printing) the problem doesn't exist, so it has to be the code. I'll post it here (it's a lot), I'm now stripping the code piece by piece trying to find out what part screws up...

Update 2:
The problem stills occurred after I stripped the complete code down to just this (pfffff, there goes my morning). :banghead:


ActiveDocument.Unprotect "********"
Dialogs(wdDialogFilePrint).Execute
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, noreset:=True, Password:="********"


So it is the security issue with the printing. I installed SP3, that didn't help. Is there a loose patch for this??

I just can't figure out why it just happens to this one user, out of the 600. I copied her ntuser.dat to a test-user, I was able to recreate the problem.

The problem does NOT occur when I do this:

ActiveDocument.Unprotect "********"
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, noreset:=True, Password:="********"
Dialogs(wdDialogFilePrint).Execute

YESSSSSSSSSS !!!!!!
JAAAAAAAAAA !!!!!!

I got it.

Strange but true.

In the final part of the coding it:
printed the document and then protected the document again.

After changing this to:
protecting the document and THEN printing it

solved the problem!!!!!!

scr*w you Bill Gates!!!! :devil:

:beerchug: :beerchug: :beerchug: :beerchug: :beerchug:

Killian
04-14-2005, 02:51 AM
Great commentary!

So what have I learned from this?
1. Sharing your problems helps, even if you end up finding your own solution
2. It always turns out to be the last thing on your list of things to check
3. It's always Bill Gates' fault (he'd probably feel bad if he weren't so damn rich)

MOS MASTER
04-14-2005, 11:23 AM
Yes...loved reading you're comments! Goed gedaan joh! :thumb