B
Bart Teems
I am getting an error condition 'Subscript out of range' - However it is not and can be proven by viewing the subscript (through a msgbbox) right before the error. Also, the error does not occur if the template is loaded manually, but occurs everytime when the template is in the startup directory. Also, the error occurs the first time, but not on subsequent times of running the macro. Also, it occurs on Word 2000, but not Word 2002. But the customer needs it to work on Word 2000
The code is ..
For i = 1 To 1
strFilename = Options.DefaultFilePath(wdUserTemplatesPath) &
Application.PathSeparator & AllTemplates(i
If FileExists(strFilename) The
' Open the Template as a template, Invisible to use
Set TheDoc = Word.Application.Documents.Open(Filename:=strFilename
' Set our variable
SetOptions TheDo
' Save the file in its original file format of templat
TheDoc.Close SaveChanges:=wdSaveChanges, OriginalFormat:=wdOriginalDocumentForma
Els
MsgBox "Could not find:" & strFilename & vbCrLf & vbCrLf & "No changes made.
lastErrorMsg = "File Not Found:" & strFilename & vbCrL
End I
Nex
And the error occurs on line two where the variable strFilename is being set. When the counter i gets to two, I get the subscript error. But on subsequent runs, it works fine. I have done everything to rearrange this code to make it work, but to no avail. Anybody got any ideas? Thanks for your help, Bart.
The code is ..
For i = 1 To 1
strFilename = Options.DefaultFilePath(wdUserTemplatesPath) &
Application.PathSeparator & AllTemplates(i
If FileExists(strFilename) The
' Open the Template as a template, Invisible to use
Set TheDoc = Word.Application.Documents.Open(Filename:=strFilename
' Set our variable
SetOptions TheDo
' Save the file in its original file format of templat
TheDoc.Close SaveChanges:=wdSaveChanges, OriginalFormat:=wdOriginalDocumentForma
Els
MsgBox "Could not find:" & strFilename & vbCrLf & vbCrLf & "No changes made.
lastErrorMsg = "File Not Found:" & strFilename & vbCrL
End I
Nex
And the error occurs on line two where the variable strFilename is being set. When the counter i gets to two, I get the subscript error. But on subsequent runs, it works fine. I have done everything to rearrange this code to make it work, but to no avail. Anybody got any ideas? Thanks for your help, Bart.