Edward Thrashcort was telling us:
Edward Thrashcort nous racontait que :
Was that really necessary?
We are talking about statements is higher versions of Word causing
compiler errors in earlier versions EVEN when inside regular If blocks
I know, have you read the whole thread or just the part where you jumped in?
Just in case, here is what I wrote earlier, complete with all the
syntactical, spelling and grammatical errors:
<quote>
Sorry about your situation, but, I created the code I posted in a Word 2003
document, saved it and ran the code.
Then, I opened the document with Word 97 and Word 2000 and ran the code
without any problems...
I have done this kind of thing before and never had any problems, so I do
not understand why you are having problems with this.
Conditioning compiling (#If) is normally used for making a difference
between a Mac or a PC machine, but regular conditional branching has always
worked for my purposes. I guess this is why there are no Compiler constants
for Word versions, they are not necessary.
Of course I cannot compile this code under Word 2000 or 97, but why would I
want to? I coded,debugged and compiled the whole thing in Word 2003.
When you run the code, the compiler only compiles the Subs/Functions you
call, this is why I suggested calling the appropriate Sub according to the
version you are running, as in my example.
I mean, the following code will not work:
'_______________________________________
Sub test()
Dim myVer As Long
myVer = Val(Left$(Application.Version, 1))
With ActiveDocument
MyName = Left(.FullName, Len(.FullName) - 4) & "_New.doc"
End With
Select Case myVer
Case 1
ActiveDocument.SaveAs FileName:=MyName, InsertLineBreaks:=True
Case 8, 9 '97 or 2000
ActiveDocument.SaveAs FileName:=MyName
Case Else
MsgBox "I don't know what you are running."
End Select
End Sub
'_______________________________________
But the code I have already posted will.
Why did you not try it?
Or if you did, what kind of error message did you get?
</quote>
And the code I refer to from an earlier mesaage is:
<quote>
'_______________________________________
Public MyName As String
'_______________________________________
Sub test()
Dim myVer As Long
myVer = Val(Left$(Application.Version, 1))
With ActiveDocument
MyName = Left(.FullName, Len(.FullName) - 4) & "_New.doc"
End With
Select Case myVer
Case 1
WordXpAndMore
Case 8, 9 '97 or 2000
Word2000AndMinus
Case Else
MsgBox "I don't know what you are running."
End Select
End Sub
'_______________________________________
'_______________________________________
Sub Word2000AndMinus()
ActiveDocument.SaveAs FileName:=MyName
End Sub
'_______________________________________
'_______________________________________
Sub WordXpAndMore()
ActiveDocument.SaveAs FileName:=MyName, InsertLineBreaks:=True
End Sub
'_______________________________________
</quote>
Would you care to test it on various versions of Word? It did work for me on
Word 2003, Word 2000 and Word 97.
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org