D
djconner
I have a program that generates a document in Word. It's an "official
document," so one of the requirements was that the output file not be
editable - or at least not *easily* editable. They wanted no options
other than "Print," so what I did is disable all Word's controls other
than printing:
==========
For Each cbar In CommandBars
For Each ctl In cbar.Controls
If ctl.Caption = "&Print" Then
ctl.Enabled = True
Else
On Error Resume Next
ctl.Enabled = False
End If
Next ctl
Next
==========
Kind of kludgy, but it got the job done. And - under Windows 2000/Word
2000 - it never interfered with the use of Word with other documents,
or after the current session.
Now, however, under Windows XP/Word 2003, it seems to be overwriting
the *default* template with the "nothing but a Print Button" setup.
Obviously, not a good thing.
I can fix this immediate problem by deleting the normal.dot file. But
another strange thing is that I can't duplicate the original error
after that. After deleting normal.dot, my program seems to run the
same as it always did, not interfering with Word in general, only with
documents generated by the program. It seems like the problem scenario
only happens once per machine, then never again.
unfortunately, I don't really have a proper test environment where I
can keep testing and retesting on a new, "clean" system.)
Would this line prevent the program from changing Word's default
behavior? Is the problem that under XP/Word 2003 the default
CustomizationContext is different?
WordApp.CustomizationContext = ActiveDocument
The context is within this code - the "CustomizationContext" line is
the only one I'm changing from previous versions:
============
Set WordDoc = CreateObject("Word.Document")
Set WordDoc = WordApp.Documents.Open(FileName:=TemplateFileName,
Format:=wdOpenFormatDocument, ReadOnly:=True)
WordApp.CustomizationContext = ActiveDocument
WordDoc.SaveAs FileName:=SavePath
============
Does this code look kosher for opening a template and saving a document
to be based on that template, without messing up other stuff?
-David
document," so one of the requirements was that the output file not be
editable - or at least not *easily* editable. They wanted no options
other than "Print," so what I did is disable all Word's controls other
than printing:
==========
For Each cbar In CommandBars
For Each ctl In cbar.Controls
If ctl.Caption = "&Print" Then
ctl.Enabled = True
Else
On Error Resume Next
ctl.Enabled = False
End If
Next ctl
Next
==========
Kind of kludgy, but it got the job done. And - under Windows 2000/Word
2000 - it never interfered with the use of Word with other documents,
or after the current session.
Now, however, under Windows XP/Word 2003, it seems to be overwriting
the *default* template with the "nothing but a Print Button" setup.
Obviously, not a good thing.
I can fix this immediate problem by deleting the normal.dot file. But
another strange thing is that I can't duplicate the original error
after that. After deleting normal.dot, my program seems to run the
same as it always did, not interfering with Word in general, only with
documents generated by the program. It seems like the problem scenario
only happens once per machine, then never again.
problem, but since I can't duplicate the problem, I'm not sure. (AndFrom researching the problem, it *seems* like this line might fix the
unfortunately, I don't really have a proper test environment where I
can keep testing and retesting on a new, "clean" system.)
Would this line prevent the program from changing Word's default
behavior? Is the problem that under XP/Word 2003 the default
CustomizationContext is different?
WordApp.CustomizationContext = ActiveDocument
The context is within this code - the "CustomizationContext" line is
the only one I'm changing from previous versions:
============
Set WordDoc = CreateObject("Word.Document")
Set WordDoc = WordApp.Documents.Open(FileName:=TemplateFileName,
Format:=wdOpenFormatDocument, ReadOnly:=True)
WordApp.CustomizationContext = ActiveDocument
WordDoc.SaveAs FileName:=SavePath
============
Does this code look kosher for opening a template and saving a document
to be based on that template, without messing up other stuff?
-David