View Single Post
 
Old 04-25-2012, 06:04 AM
RichardP RichardP is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Apr 2012
Location: France 80%, UK 20%
Posts: 9
RichardP is on a distinguished road
Smile Late binding must be the way to go

Thanks so much Paul, very helpful.
Importing 132 modules each time I update my AddIn is too complicated.
I have checks in my code for argument separator (,/ and other French specifics, and I'm carfeful not to use any features introduced with Word 2010 (I originally developed the AddIn in Word 2003 and hope to make this 2010 version backward compatible, thanks to you).

So late binding must be the way to go (I lose Intellisense, don't I?)
In practice, does this mean I should change all my Dim xlApp as Excel.Application to Dim xlApp as Object (and likewise for ppApp, olApp)?

I have one class module that may be a problem and I'm not sure how to handle late binding in this respect. Here's the (fairly self-explanatory) code:

'''=========ThisApplication.cls
Option Explicit
Public WithEvents oApp As Word.Application
------------------------------
Private Sub PsuedoAutoNew()
Show_WOTTToolBar
ViewSet "New"
ZoomSet "New"
End Sub

Private Sub PsuedoAutoOpen()
Show_WOTTToolBar
ViewSet "Existing"
ZoomSet "Existing"
End Sub

Should I change Public WithEvents oApp As Word.Application to ... As Object? Then write a Class_Initialize() and Class_Terminate()?

And in the code module containing the AddIn's Autoexec:

'''======= Support_Autoexec.bas
Option Explicit
Dim oAppClass As New ThisApplication 'i.e. new instance of class named 'ThisApplication' (see class module)
Public oldNoOfOpenDocs As Long
Public FirstNewDoc As Boolean

Public Sub Autoexec
'''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''''''''''''''''''''''''''''
'NB This only fires if this .dot(m) is a global template, i.e. in Word's Startup 'folder. It doesn't fire if this file is opened anywhere else
' THIS Autoexec fires AFTER the one in Normal.dot(m) '
' and BEFORE the routines in the ThisApplication class module '
'''''''''''''''''''''''''''''''''''''''''''''''''' '''''''''''''''''''''''''''''''''''
Set oAppClass.oApp = Word.Application
oldNoOfOpenDocs = 0
FirstNewDoc = True
"PUT ALL START-UP CODE HERE: WOTT Menu, WOTT Toolbar, WOTT Word 'settings,WOTT keyboard assignments etc.
A_InitWOTT
End Sub

Thanks in advance for your invaludable advice

Richard
Reply With Quote