Re: Word Programming - issue with Word versions and automation

Tech-Archive recommends: Fix windows errors by optimizing your registry



> I know, have you read the whole thread or just the part where you jumped

Evidently I may have missed some messages.
Apologies. I had not associated that message with you.

> > Keep up Bond!
>
> Was that really necessary?

Maybe you don't understand English humour? It was meant as a friendly
rebuke - albeit that it turned out I was wrong!

No offense intended.

I'm glad the the problem is solved by compiling only in 2003. However I am
surprised that Jon West's suggestion works - it will still work in earlier
version. I assume it's being distributed as an executable addin?


Eddie


> Edward Thrashcort was telling us:
> Edward Thrashcort nous racontait que :
>
> > Keep up Bond!
>
> 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
> jmarcilREMOVE@xxxxxxxxxxxxxxxxxxxxxxx
> Word MVP site: http://www.word.mvps.org
>
>
>

.



Relevant Pages

  • Re: Word Programming - issue with Word versions and automation
    ... Edward Thrashcort nous racontait que: ... I guess this is why there are no Compiler constants ... Sub test() ... Dim myVer As Long ...
    (microsoft.public.word.vba.general)
  • Re: performance of subs vs. functions
    ... The compiler does not produce any functional code for the two examples. ... In fact I had to force the function or sub to do something before the compiler produced any real ... Public Function StubFunc() As Boolean ... Public Sub StubSub() ...
    (microsoft.public.vb.general.discussion)
  • Re: Integer Dos And Donts
    ... Public Class MainForm ... //000009: Public Shared Sub Main ... Imports Int = System.Int64 ... Only one compiler is needed. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Overloaded constructors
    ... constructors with a private initialization function is indeed the perfect ... class as the first line of the Sub New. ... Public Sub New ... the compiler knows that it doesn't need to call the base ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Assumed shape array help
    ... >> call sub ) ... >> subroutine sub ... >> by use of a nasty explicit interface/module, the compiler still checks ... > dimensional arrays. ...
    (comp.lang.fortran)