View Single Post
 
Old 04-25-2012, 04:49 PM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi Richard,

What you can do is use early binding for the development, then convert to late binding once you're done.

As you know, when using late binding, the calling app has no access to the called app's object model until the code is compiled. Thus, if you're automating Word from Excel with late binding, Excel has no way of knowing what wdBorderTop or wdLineStyleSingle, for example, are. If, having developed the code with early binding, you'd prefer to leave parameters like wdBorderTop and wdLineStyleSingle unchanged, you could declare them beforehand with code like:
Const wdBorderTop As Long = -1
Const wdLineStyleSingle As Long = 1

This has the advantage that, even with late binding, you can continue to use expressions like:
.Borders(wdBorderTop).LineStyle = wdLineStyleSingle
which, of course, are much easier to interpret than:
.Borders(-1).LineStyle = 1
Plus, you then don't have to go through your code and change every instance of 'wdLineStyleSingle' to '-1'. It also makes it easy to switch back & forth between early & late binding for code maintenance/enhancement.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote