Excel Object Library 10.0 vs 11.0 version
Excel Object Library 10.0 vs 11.0 version
Excel Object Library 10.0 vs 11.0 version
Excel Object Library 10.0 vs 11.0 version
Excel Object Library 10.0 vs 11.0 version
Excel Object Library 10.0 vs 11.0 version Excel Object Library 10.0 vs 11.0 version Excel Object Library 10.0 vs 11.0 version Excel Object Library 10.0 vs 11.0 version Excel Object Library 10.0 vs 11.0 version Excel Object Library 10.0 vs 11.0 version Excel Object Library 10.0 vs 11.0 version Excel Object Library 10.0 vs 11.0 version
Excel Object Library 10.0 vs 11.0 version Excel Object Library 10.0 vs 11.0 version
Excel Object Library 10.0 vs 11.0 version
Go Back  Xtreme Visual Basic Talk > > > Excel Object Library 10.0 vs 11.0 version


Reply
 
Thread Tools Display Modes
  #1  
Old 01-06-2012, 03:40 AM
quba2001 quba2001 is offline
Newcomer
 
Join Date: Jan 2012
Posts: 1
Post Excel Object Library 10.0 vs 11.0 version


I have 2003 xls file which is saved on a web share point. File combines vbs functionalities, of which one is uploading data to this file (from another file on the same share point) by clicking command button.



When I open file from my location it all functionalities are working without problems.



My customer is running it from his location, he is also using Excel 2003, the moment he wants to upload the data he gets the bug.

Message: Method "Worksheets" of object "_Global" failed



I checked and it seems that in the references he has 10.0 object library and I have 11.0



What i can do to unify the coding so it is indifferent from Object Library version?



Pls see coding below (in bold where it is currently buging)

I have read about late va early binding, I guess i'm using late binding
I also check that i can adjust late binding buy standard codes.

Dim oExcel As Object
Dim oWorkbook As Object
Dim oWorksheet As Object
Set oExcel = CreateObject("Excel.Application")
Set oWorkbook = oExcel.Workbooks.Add
Set oWorksheet = oExcel.Worksheets.Add

I do not know where I have to put this coding
Ok Dim will come on top of my coding, before any sub is open
and Set code ???

Should I apply it to the overall workbook?


--------------------------------------------------------------------------------

Private Sub CommandButton1_Click() 'AP_AR upload

' data upload from Oracle AP_AR_TOTALS file


r = 7
r1 = 5

currWorkbook = ThisWorkbook.Name
sFolder = Worksheets("Welcome").TextBox3.Value

fName = "AP_AR_TOTALS.xls" 'name of AP_AR total file
sorceLocation = "http://infoshare.common.eu.corp.toyota.com/VAT/" & "TGB" & "/CURRENTMONTH/Shared%20Documents/" & "AP_AR_TOTALS.xls"


If CommandButton3 = False Then

Application.Workbooks.Open Filename:=sorceLocation 'AP_AR total file activation

Do While Workbooks(fName).Worksheets("AP_AR_TOTALS").Cells(r, 7) <> "END" 'adjust tab name !!!!

Workbooks(currWorkbook).Worksheets("Tax Master Tab").Cells(r1, 1) = Workbooks(fName).Worksheets("AP_AR_TOTALS").Cells(r, 1)
Workbooks(currWorkbook).Worksheets("Tax Master Tab").Cells(r1, 2) = Workbooks(fName).Worksheets("AP_AR_TOTALS").Cells(r, 2)
Workbooks(currWorkbook).Worksheets("Tax Master Tab").Cells(r1, 3) = Workbooks(fName).Worksheets("AP_AR_TOTALS").Cells(r, 3)
Workbooks(currWorkbook).Worksheets("Tax Master Tab").Cells(r1, 4) = Workbooks(fName).Worksheets("AP_AR_TOTALS").Cells(r, 4)
Workbooks(currWorkbook).Worksheets("Tax Master Tab").Cells(r1, 5) = Workbooks(fName).Worksheets("AP_AR_TOTALS").Cells(r, 5)
Workbooks(currWorkbook).Worksheets("Tax Master Tab").Cells(r1, 6) = Workbooks(fName).Worksheets("AP_AR_TOTALS").Cells(r, 6)

r1 = r1 + 1
Workbooks(currWorkbook).Worksheets("Tax Master Tab").Rows(r1).EntireRow.Insert
r = r + 1
Loop
Workbooks(currWorkbook).Worksheets("Recon.").Cells(2, 1) = Workbooks(fName).Worksheets("AP_AR_TOTALS").Cells(2, 4)
Workbooks(currWorkbook).Worksheets("Recon.").Cells(4, 1) = Workbooks(fName).Worksheets("AP_AR_TOTALS").Cells(3, 4)
End If

Thank you for your suport
Reply With Quote
  #2  
Old 01-11-2012, 04:51 PM
DennisW's Avatar
DennisW DennisW is offline
Junior Contributor
 
Join Date: Mar 2006
Location: Östersund, Sweden
Posts: 268
Default

Hi,
Yes, it's indeed late binding You use. Because Your client has 10.0 and You 11.0 You must use late binding.

As for the code You need to cast the oWorksheet to the Excel.Worksheet Object like:

Code:
oWorksheet = TryCast(oExcel.Worksheets.Add(), Excel.Worksheet)
__________________
Kind regards,
Dennis

.NET & Excel | 2nd edition PED | MVP
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Excel Object Library 10.0 vs 11.0 version
Excel Object Library 10.0 vs 11.0 version
Excel Object Library 10.0 vs 11.0 version Excel Object Library 10.0 vs 11.0 version
Excel Object Library 10.0 vs 11.0 version
Excel Object Library 10.0 vs 11.0 version
Excel Object Library 10.0 vs 11.0 version Excel Object Library 10.0 vs 11.0 version Excel Object Library 10.0 vs 11.0 version Excel Object Library 10.0 vs 11.0 version Excel Object Library 10.0 vs 11.0 version Excel Object Library 10.0 vs 11.0 version Excel Object Library 10.0 vs 11.0 version
Excel Object Library 10.0 vs 11.0 version
Excel Object Library 10.0 vs 11.0 version
 
Excel Object Library 10.0 vs 11.0 version
Excel Object Library 10.0 vs 11.0 version
 
-->