References for VBA Project across Office versions (1 Viewer)

lauro

Member
Local time
Today, 09:43
Joined
May 18, 2012
Messages
59
Hi,
I'm developing an application based on Word and Access and their inter operation, for version 2007 and later.
I wrote an InnoSetup procedure for the installation.

I have the following problem:

I compiled the Word Template and the Access database in Office 2013.
When I install in Office 2010 the following problems with references occur.
  • Missing or not selected in the Word Project. :
    • Microsoft Forms 2.0 Object Library,
    • Microsoft Scripting Runtime
    • Microsoft Access 14.0 Object Library
  • Missing in Access
    • Microsoft Word 14.0 Object Library
What should I do?

  1. Having different Word Template and Access Database for each versions, and check at InnoSetup installation time which files install?
  2. Set all (different versions) references in the two projects?
  3. Conditionally set the references based on the version of Office? (Is it possible?)
Thanks, Lauro
 

sneuberg

AWF VIP
Local time
Today, 09:43
Joined
Oct 17, 2014
Messages
3,506
Following on to moke123's reference you can develop with early binding and then deploy with late binding. You can use conditional compilation. Below is an example of what we did in our Word programming. Moke123's reference states that a program will run slow with late binding but I found the opposite to be true. For some reason our code runs faster with late binding.



Code:
#Const LateBinding = True

#If LateBinding Then
    Const wdAlignRowCenter = 1
    Const wdLineStyleSingle = 1
    Const wdLineStyleNone = 0
    Const wdRowHeightExactly = 2
    Const wdBorderLeft = -2
    Const wdBorderRight = -4
    Const wdCollapseStart = 1
    Const wdWrapInline = 7
    Const wdAlignParagraphRight = 2
    Const wdStory = 6
    Const wdMove = 0
    Const wdBorderVertical = -6
    Const wdHeaderFooterPrimary = 1
    Const wdCollapseEnd = 0
    Const wdLineSpaceExactly = 4
    Const wdRowHeightAuto = 0
    Const wdDoNotSaveChanges = 0
    
    Dim apWord As Object
    Dim doc As Object
    Dim sel As Object
    Dim docHeader As Object
    Dim BannerShape As Object
    Dim WhatIsIt As Object
    Dim Image1Shape As Object
    Dim Image2Shape As Object
    Dim What As Object
    Dim Disclaimer As Object
    Dim BlackLine As Object
    Dim WhatIncluded As Object
    Dim ppTable1 As Object
    Dim ppTable1Range As Object
    Dim rng As Object
    Dim shp As Object
    Dim TempParagraph As Object
    Dim totalTable As Object
    Dim totalTableRange As Object
    Dim pptable2 As Object
    Dim MyRange2 As Object
    
#Else

    
    Dim apWord As Word.Application
    Dim doc As Word.Document
    Dim doc As Word.Document
    Dim sel As Word.Selection
    Dim docHeader As Word.HeaderFooter
    Dim BannerShape As Word.Shape
    Dim WhatIsIt As Word.Shape
    Dim Image1Shape As Word.Shape
    Dim Image2Shape As Word.Shape
    Dim What As Word.Shape
    Dim Disclaimer As Word.Shape
    Dim BlackLine As Word.Shape
    Dim WhatIncluded As Word.Shape
    Dim ppTable1 As Word.Table
    Dim ppTable1Range As Word.Range
    Dim rng As Word.Range
    Dim shp As Word.Shape
    Dim TempParagraph As Word.Paragraph
    Dim totalTable As Word.Table
    Dim totalTableRange As Word.Range
    Dim pptable2 As Word.Table
    Dim MyRange2 As Word.Range
    
#End If
 

lauro

Member
Local time
Today, 09:43
Joined
May 18, 2012
Messages
59
Thanks for your answers.


So, I have to make a choice between the two options:
1. Compile my Access and Word projects in VBA 2007 and let (or hope that) later versions of Office to make the necessary adjustment.
2. Rewrite all the declarations (and initializations) in my code so to have a conditional compiling: early binding while developing, late binding when delivering)
It’s not an easy decision.
It seems that the latter (late binding) will save me with whatever problem may arise with different versions of Office; on the other and it will be a lot of work to rewrite all my code; and maybe the program will run slower.
The former (write in 2007) seems much easier but it will oblige me to work with an obsolete version of Office and most user will read on top of the Word application the annoying notice “Compatibility mode”.
Lauro
 

speakers_86

Registered User.
Local time
Today, 12:43
Joined
May 17, 2007
Messages
1,919
Late binding is always a good idea. Early binding may not work across different computers. It's unfortunate, but that's the way it is.
 

lauro

Member
Local time
Today, 09:43
Joined
May 18, 2012
Messages
59
Yes.
but I discovered that #Const LateBinding = true has to be declared at module level (cannot be public), and when you have dozens of module is not very easy to test changing the value in so many places,
 

sneuberg

AWF VIP
Local time
Today, 09:43
Joined
Oct 17, 2014
Messages
3,506
How about in one module Press Ctrl H then fill in like



Note that Current Project is selected under Search. Then click Replace All. You can do this when you want to switch back and forth.

Edit: What's really the pain is adding and removing the references. That list must be a mile long and I hate it that it doesn't x in the box when I click on a reference. I suppose there is someway to do this programmatically.
 

Attachments

  • ReplaceDialog.jpg
    ReplaceDialog.jpg
    58.2 KB · Views: 658
Last edited:

lauro

Member
Local time
Today, 09:43
Joined
May 18, 2012
Messages
59
Thanks again for this other suggestion.
Lauro
 

Users who are viewing this thread

Top Bottom