B
Brendan
I have a template that has the below code (which is identical) and runs
either on a New document from the template or after the document has been
saved and then opened at a later date. If I open the doucment from FILE,
NEW, Templates on My Computer, and select the "Create New" - Template Radio
button (bottom right of templates tabs), then I get no error. However, if I
select the "Document" radio button in the bottom right, the document errors
out with the Error 91 Code and the "Object Variable....Not set. Here is the
code:
Sub AutoNew()
ActiveWindow.ActivePane.DisplayRulers = True 'display the rulers
ActiveWindow.ActivePane.View.ShowAll = False 'turn off the formatting
command view
With ActiveWindow.View
.Type = wdPrintView 'select page/print layout view
'Alternative to the above line if normal view is preferred
'.Type = wdNormalView
.Zoom.Percentage = 100 'set the display zoom to 100%
.FieldShading = wdFieldShadingWhenSelected 'set the field shading
preference
.ShowFieldCodes = False 'turn off field code display
.DisplayPageBoundaries = True 'Turn on white space between pages
End With
'CommandBars("Reviewing").Visible = False 'Turn off the reviewing toolbar
Message = "Just Start Typing and TAB to next field - New"
Title = "Sales Widget Instructions" ' Define title.
Response = MsgBox(Message, vbOKOnly, Title)
ActiveDocument.Bookmarks("swNumber").Select
ActiveDocument.Sections(2).ProtectedForForms = False
ActiveDocument.Sections(3).ProtectedForForms = False
End Sub
-------------------------------------------------------------------------------------
Private Sub Document_Open()
ActiveWindow.ActivePane.DisplayRulers = True 'display the rulers
ActiveWindow.ActivePane.View.ShowAll = False 'turn off the formatting
command view
With ActiveWindow.View
.Type = wdPrintView 'select page/print layout view
'Alternative to the above line if normal view is preferred
'.Type = wdNormalView
.Zoom.Percentage = 100 'set the display zoom to 100%
.FieldShading = wdFieldShadingWhenSelected 'set the field shading
preference
.ShowFieldCodes = False 'turn off field code display
.DisplayPageBoundaries = True 'Turn on white space between pages
End With
'CommandBars("Reviewing").Visible = False 'Turn off the reviewing toolbar
Message = "Welcome Back!"
Title = "Sales Widget Instructions" ' Define title.
Response = MsgBox(Message, vbOKOnly, Title)
ActiveDocument.Bookmarks("swNumber").Select
ActiveDocument.Sections(2).ProtectedForForms = False
ActiveDocument.Sections(3).ProtectedForForms = False
End Sub
either on a New document from the template or after the document has been
saved and then opened at a later date. If I open the doucment from FILE,
NEW, Templates on My Computer, and select the "Create New" - Template Radio
button (bottom right of templates tabs), then I get no error. However, if I
select the "Document" radio button in the bottom right, the document errors
out with the Error 91 Code and the "Object Variable....Not set. Here is the
code:
Sub AutoNew()
ActiveWindow.ActivePane.DisplayRulers = True 'display the rulers
ActiveWindow.ActivePane.View.ShowAll = False 'turn off the formatting
command view
With ActiveWindow.View
.Type = wdPrintView 'select page/print layout view
'Alternative to the above line if normal view is preferred
'.Type = wdNormalView
.Zoom.Percentage = 100 'set the display zoom to 100%
.FieldShading = wdFieldShadingWhenSelected 'set the field shading
preference
.ShowFieldCodes = False 'turn off field code display
.DisplayPageBoundaries = True 'Turn on white space between pages
End With
'CommandBars("Reviewing").Visible = False 'Turn off the reviewing toolbar
Message = "Just Start Typing and TAB to next field - New"
Title = "Sales Widget Instructions" ' Define title.
Response = MsgBox(Message, vbOKOnly, Title)
ActiveDocument.Bookmarks("swNumber").Select
ActiveDocument.Sections(2).ProtectedForForms = False
ActiveDocument.Sections(3).ProtectedForForms = False
End Sub
-------------------------------------------------------------------------------------
Private Sub Document_Open()
ActiveWindow.ActivePane.DisplayRulers = True 'display the rulers
ActiveWindow.ActivePane.View.ShowAll = False 'turn off the formatting
command view
With ActiveWindow.View
.Type = wdPrintView 'select page/print layout view
'Alternative to the above line if normal view is preferred
'.Type = wdNormalView
.Zoom.Percentage = 100 'set the display zoom to 100%
.FieldShading = wdFieldShadingWhenSelected 'set the field shading
preference
.ShowFieldCodes = False 'turn off field code display
.DisplayPageBoundaries = True 'Turn on white space between pages
End With
'CommandBars("Reviewing").Visible = False 'Turn off the reviewing toolbar
Message = "Welcome Back!"
Title = "Sales Widget Instructions" ' Define title.
Response = MsgBox(Message, vbOKOnly, Title)
ActiveDocument.Bookmarks("swNumber").Select
ActiveDocument.Sections(2).ProtectedForForms = False
ActiveDocument.Sections(3).ProtectedForForms = False
End Sub