Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 610
  • Last Modified:

Late Binding in Access

I am refering to Excel 2003 in my Access code as below:

Dim xls As New Excel.Application
Dim wks As Excel.worksheet
Dim wkb As Excel.Workbook

How do I change it to late binding as some of my client use Excel 2007?

I want to set as early binding to Excel  2003, check the binding at startup and change the binding if EXcel 2003 dose not exist.



0
howardching
Asked:
howardching
2 Solutions
 
Patrick MatthewsCommented:
howardching said:
>>I want to set as early binding to Excel  2003, check the binding at startup and change the binding
>>if EXcel 2003 dose not exist.

I doubt you can do that.  I would just go with late binding throughout.

Dim xls As Object 'New Excel.Application
Dim wks As Object 'Excel.worksheet
Dim wkb As Object 'Excel.Workbook

Set xls = CreateObject("Excel.Application")
0
 
howardchingAuthor Commented:
When I try to execute your code by adding the following line

wks.cells(1, 1) = "One:"

I encounter error message as below:

"Object Variable or With block variable not set"
0
 
frankyteeCommented:
have you set wks object?
after your declarations, something like

Set xls = CreateObject("Excel.Application")
Set wkb = xls.Workbooks.Open("whateverfile.xls") 'or add a new workbook
Set wks = wkb.Worksheets("sheet1") 'whatever sheet
wks.cells(1, 1) = "One:"    
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
peter57rCommented:
In view of your problems so far, I would suggest you develop your code initially using normal early binding and make sure you get something that works.
Then do the changes needed to convert to late binding.  
0
 
Patrick MatthewsCommented:
peter57r,

Always a good strategy :)

Regards,

Patrick
0
 
howardchingAuthor Commented:
Yes but whenever I debug the program, I have to re-set it to early binding and then late binding
0
 
Patrick MatthewsCommented:
howardching said:
>>Yes but whenever I debug the program, I have to re-set it to early binding and then late binding

Why?  You can debug with early or late binding.
0
 
howardchingAuthor Commented:
Yes but your can only debug WITHOUT IntelliSense Support.
0
 
Patrick MatthewsCommented:
howardching said:
>>Yes but your can only debug WITHOUT IntelliSense Support.

Every silver lining has its cloud :)
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now