Michael Bednarek was telling us:
Michael Bednarek nous racontait que :
Shot in the dark:
Function WordVersion() As Single
Dim wrdObj As Object
...
I am not sure, but I have tried something like that before and found that it
was impossible to declare your own Compiler constant. I took your code and
twisted it around to test it in Word 2003:
'_______________________________________
Function WordVersion() As Single
Dim wrdObj As Object
Set wrdObj = CreateObject("Word.Basic")
WordVersion = Val(wrdObj.AppInfo(2)) ' Word Version
End Function
'_______________________________________
'_______________________________________
Sub test()
If WordVersion = 9 Then
#Const WrdVer = 9 'Word 2000 = 9
End If
#If WrdVer = 9 Then
ActiveDocument.SaveAs FileName:=sDocName, FileFormat:=iFormat
#Else
ActiveDocument.SaveAs FileName:=sDocName, FileFormat:=iFormat,
InsertLineBreaks:=True
#End If
End Sub
'_______________________________________
So, under 2003, the Else statement should get executed, right? Or did I miss
something?
But in fact, it is the If statement that gets executed, as if the value of
WrdVer did not matter.
Or am I doing something wrong?
Finally, is there a reason for using:
'_______________________________________
Function WordVersion() As Single
Dim wrdObj As Object
Set wrdObj = CreateObject("Word.Basic")
WordVersion = Val(wrdObj.AppInfo(2)) ' Word Version
End Function
'_______________________________________
instead of something like:
'_______________________________________
Dim WordVersion As Long
WordVersion = Val(Left$(Application.Version, 2))
'_______________________________________
in the same procedure?
(I am not asking so much about the branching out, which maybe useful if you
have many different module that have to check the Word version, but more
about the CreateObject("Word.Basic") aspect of the function...)
--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site:
http://www.word.mvps.org