Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi
in the few lines of code below which was from Dave Petersen and Joe U, the use of the Excel command ForceFullCalculation does not produce a standard compilation error (due to late binding apparently), whereas it would if it was just Thisworkbook.ForceFullCalculation If Val(Application.Version) 11 Then Set oWkBk = ThisWorkbook oWkBk.ForceFullCalculation = True Debug.Print "Running forced calculation" End If Can someone explain briefly WHY late binding applies in this area? Many thanks Tim |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Just my thoughts -- could be completely wrong technically. But it satisfies my
curiosity <vbg. Excel knows all the properties and methods for ThisWorkbook just like it knows all the properties and methods for a Range object. But it has no idea what you're doing with a variable declared as an Object. So no matter what version you're using if you use ThisWorkbook, excel knows -- you can't fool it. But if you use the Object variable, excel doesn't know or care until the code actually runs. On 12/16/2011 05:02, Tim Childs wrote: Hi in the few lines of code below which was from Dave Petersen and Joe U, the use of the Excel command ForceFullCalculation does not produce a standard compilation error (due to late binding apparently), whereas it would if it was just Thisworkbook.ForceFullCalculation If Val(Application.Version) 11 Then Set oWkBk = ThisWorkbook oWkBk.ForceFullCalculation = True Debug.Print "Running forced calculation" End If Can someone explain briefly WHY late binding applies in this area? Many thanks Tim -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
On 16/12/2011 11:02, Tim Childs wrote:
Hi in the few lines of code below which was from Dave Petersen and Joe U, the use of the Excel command ForceFullCalculation does not produce a standard compilation error (due to late binding apparently), whereas it would if it was just Thisworkbook.ForceFullCalculation If Val(Application.Version) 11 Then Set oWkBk = ThisWorkbook oWkBk.ForceFullCalculation = True Debug.Print "Running forced calculation" End If Can someone explain briefly WHY late binding applies in this area? Excel doesn't bother to check if the object oWkBk can execute the statement "ForceFullCalculation = True" until it reaches that line. Protected with this code you can insert completely invalid invocations of non-existent and fictitious methods of oWkBk eg. oWkBk.Zork Xyzzy = "Hello Sailor" It will give a runtime error 438 "Object doesn't support property of method" if you ever execute the line but not until. So it is quite a clever way to hide Version related incompatibilities from the compiler. I am pretty sure no versions of XL ever supported the Zork method. (a prehistoric text based adventure game) Regards, Martin Brown |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Martin and Dave
MANY thanks for those responses - interesting to hear what the experts get up to with overcoming version incompatibilities. best wishes Tim ("Qu: Upgrades - Progress isn't all what it's cracked up to be?"). "Martin Brown" wrote in message ... On 16/12/2011 11:02, Tim Childs wrote: Hi in the few lines of code below which was from Dave Petersen and Joe U, the use of the Excel command ForceFullCalculation does not produce a standard compilation error (due to late binding apparently), whereas it would if it was just Thisworkbook.ForceFullCalculation If Val(Application.Version) 11 Then Set oWkBk = ThisWorkbook oWkBk.ForceFullCalculation = True Debug.Print "Running forced calculation" End If Can someone explain briefly WHY late binding applies in this area? Excel doesn't bother to check if the object oWkBk can execute the statement "ForceFullCalculation = True" until it reaches that line. Protected with this code you can insert completely invalid invocations of non-existent and fictitious methods of oWkBk eg. oWkBk.Zork Xyzzy = "Hello Sailor" It will give a runtime error 438 "Object doesn't support property of method" if you ever execute the line but not until. So it is quite a clever way to hide Version related incompatibilities from the compiler. I am pretty sure no versions of XL ever supported the Zork method. (a prehistoric text based adventure game) Regards, Martin Brown |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
From Early binding to Late binding | Excel Programming | |||
Using ADO and Late Binding | Excel Programming | |||
Late Binding examples of binding excel application | Excel Programming | |||
Late Binding help, Please | Excel Programming | |||
EARLY binding or LATE binding ? | Excel Programming |