Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Compiling and Late Binding

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 420
Default Compiling and Late Binding

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 230
Default Compiling and Late Binding

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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Compiling and Late Binding

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
From Early binding to Late binding Henk Excel Programming 1 February 12th 09 11:37 AM
Using ADO and Late Binding Jan T. Excel Programming 4 July 2nd 07 12:47 PM
Late Binding examples of binding excel application HeatherO Excel Programming 13 March 17th 05 08:19 AM
Late Binding help, Please Bud Dean Excel Programming 5 September 24th 04 04:31 AM
EARLY binding or LATE binding ? jason Excel Programming 6 February 26th 04 04:57 PM


All times are GMT +1. The time now is 01:50 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"