P
Pat Sullivan
Hi,
I get the error "Word has encountered a problem and needs to close. We are
sorry for the inconvenience." when I create a document from a template using
File...New. The error occurs after the AutoNew subroutine ends.
If I double-click the template file in Windows Explorer, the AutoNew
subroutine works fine. Opening a doucment that is attached to the template
(running the AutoOpen subroutine using the same code) works fine also.
I am using Word 2003, and the macro checks if the "Windows in Taskbar" is
checked. If so, I want to uncheck it so that a Userform that opens multiple
documents will remain in view. At the end, I want to re-check "Windows in
Taskbar", if that was the original user setting.
Does anyone know what is causing this behaviour & if there is a way around
it?
This is the code used in the template file .....
Public ShowTasks As Boolean
Dim WordVer As String
Dim VerNum As Double
Dim VerInt As Integer
Sub AutoOpen()
Call TurnOffSDI ' so Userform remains in view
'
' Code to ... Load Userform & open multiple documents
'
Call TurnOnSDI ' return to original user setting
End Sub
Sub AutoNew()
Call TurnOffSDI ' so Userform remains in view
'
' Code to ... Load Userform & open multiple documents
'
Call TurnOnSDI ' return to original user setting
End Sub
Sub TurnOffSDI()
' If later than W2000 (or version 9.0)- turn off the SDI feature
ShowTasks = False
WordVer = Application.Version ' get Word version#
VerNum = Val(WordVer) ' convert to decimal number & remove
possible alpha suffix(i.e. for SRs prior to W2000)
VerInt = Int(VerNum) ' truncate to get version#
(11=W2003,10=W2002,9=W2000,8=W97,7=W95)
If VerInt > 9 Then
Call SDIOffWord10 ' call if version later than Word2000
End If
End Sub
Sub TurnOnSDI()
' If later than W2000 (or version 9.0)- turn on the SDI feature
WordVer = Application.Version ' get Word version#
VerNum = Val(WordVer) ' convert to decimal number
VerInt = Int(VerNum) ' truncate to get version#
(11=W2003,10=W2002,9=W2000,8=W97,7=W95)
If VerInt > 9 Then
Call SDIOnWord10 ' call if version later than Word2000
End If
End Sub
Sub SDIOffWord10()
' ShowTasks is true if user setting at Tools|Options|View...Windows in
Taskbar is checked
If Application.ShowWindowsInTaskbar Then ShowTasks = True
Application.ShowWindowsInTaskbar = False
End Sub
Sub SDIOnWord10()
' ShowTasks is true if user setting at Tools|Options|View...Windows in
Taskbar is checked
If ShowTasks Then Application.ShowWindowsInTaskbar = True
End Sub
I get the error "Word has encountered a problem and needs to close. We are
sorry for the inconvenience." when I create a document from a template using
File...New. The error occurs after the AutoNew subroutine ends.
If I double-click the template file in Windows Explorer, the AutoNew
subroutine works fine. Opening a doucment that is attached to the template
(running the AutoOpen subroutine using the same code) works fine also.
I am using Word 2003, and the macro checks if the "Windows in Taskbar" is
checked. If so, I want to uncheck it so that a Userform that opens multiple
documents will remain in view. At the end, I want to re-check "Windows in
Taskbar", if that was the original user setting.
Does anyone know what is causing this behaviour & if there is a way around
it?
This is the code used in the template file .....
Public ShowTasks As Boolean
Dim WordVer As String
Dim VerNum As Double
Dim VerInt As Integer
Sub AutoOpen()
Call TurnOffSDI ' so Userform remains in view
'
' Code to ... Load Userform & open multiple documents
'
Call TurnOnSDI ' return to original user setting
End Sub
Sub AutoNew()
Call TurnOffSDI ' so Userform remains in view
'
' Code to ... Load Userform & open multiple documents
'
Call TurnOnSDI ' return to original user setting
End Sub
Sub TurnOffSDI()
' If later than W2000 (or version 9.0)- turn off the SDI feature
ShowTasks = False
WordVer = Application.Version ' get Word version#
VerNum = Val(WordVer) ' convert to decimal number & remove
possible alpha suffix(i.e. for SRs prior to W2000)
VerInt = Int(VerNum) ' truncate to get version#
(11=W2003,10=W2002,9=W2000,8=W97,7=W95)
If VerInt > 9 Then
Call SDIOffWord10 ' call if version later than Word2000
End If
End Sub
Sub TurnOnSDI()
' If later than W2000 (or version 9.0)- turn on the SDI feature
WordVer = Application.Version ' get Word version#
VerNum = Val(WordVer) ' convert to decimal number
VerInt = Int(VerNum) ' truncate to get version#
(11=W2003,10=W2002,9=W2000,8=W97,7=W95)
If VerInt > 9 Then
Call SDIOnWord10 ' call if version later than Word2000
End If
End Sub
Sub SDIOffWord10()
' ShowTasks is true if user setting at Tools|Options|View...Windows in
Taskbar is checked
If Application.ShowWindowsInTaskbar Then ShowTasks = True
Application.ShowWindowsInTaskbar = False
End Sub
Sub SDIOnWord10()
' ShowTasks is true if user setting at Tools|Options|View...Windows in
Taskbar is checked
If ShowTasks Then Application.ShowWindowsInTaskbar = True
End Sub