473,769 Members | 7,650 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

excel interop - how to avoid late binding?

GS
I have installed the ms PIA for ofc XP, and followed the article
http://support.microsoft.com/kb/247412/
trying to paste into a worksheet

However I got late binding not allowed errors
....
webOCWraooer,Co py // get the desired data into clapboard

'Create a new workbook in Excel
Dim oExcel As Object
Dim oBook As Object
Set oExcel = CreateObject("E xcel.Applicatio n")
Set oBook = oExcel.Workbook s.Add ' < option strict on disallows late
binding>
'Paste the data
oBook.Worksheet s(1).Range("A1" ).Select ' < option strict on disallows
late binding>

oBook.Worksheet s(1).Paste ' < option strict on disallows late binding>

so I tried

....
Dim oExcel As Excel.Applicati on
Dim oBook As Excel.Workbook
oExcel = New Excel.Applicati on
oBook = oExcel.Workbook s.Add ' so far so good
'Paste the data
oBook.Worksheet s(1).Range("A1" ).Select() ' oops late binding
error
oBook.Worksheet s(1).Paste() ' same as above

How do get around the last two?

I tried
oSheet As Excel.Worksheet s
Dim oRange As Excel.Range

oSheet = oBook.ActiveShe ets(1)
but that did not help
please Help


Jun 16 '07 #1
2 8348
GS
Now I have cut down the errors to one:
Dim oSheet As Excel.Worksheet
Dim oRange As Excel.Range

oSheet = oExcel.ActiveWo rkbook.ActiveSh eet() ' < still
implicit conv form obj to microsoft.offic e.interop.excel .worksheet
' also tried oExcel.ActiveSh eet
' do not work: oBook.Worksheet s(1) 'oBook.Sheets

"GS" <gs************ **********@msne ws.Nomail.comwr ote in message
news:Oy******** ******@TK2MSFTN GP06.phx.gbl...
I have installed the ms PIA for ofc XP, and followed the article
http://support.microsoft.com/kb/247412/
trying to paste into a worksheet

However I got late binding not allowed errors
...
webOCWraooer,Co py // get the desired data into clapboard

'Create a new workbook in Excel
Dim oExcel As Object
Dim oBook As Object
Set oExcel = CreateObject("E xcel.Applicatio n")
Set oBook = oExcel.Workbook s.Add ' < option strict on disallows late
binding>
'Paste the data
oBook.Worksheet s(1).Range("A1" ).Select ' < option strict on disallows
late binding>

oBook.Worksheet s(1).Paste ' < option strict on disallows late
binding>
>
so I tried

...
Dim oExcel As Excel.Applicati on
Dim oBook As Excel.Workbook
oExcel = New Excel.Applicati on
oBook = oExcel.Workbook s.Add ' so far so good
'Paste the data
oBook.Worksheet s(1).Range("A1" ).Select() ' oops late binding
error
oBook.Worksheet s(1).Paste() ' same as above

How do get around the last two?

I tried
oSheet As Excel.Worksheet s
Dim oRange As Excel.Range

oSheet = oBook.ActiveShe ets(1)
but that did not help
please Help


Jun 16 '07 #2
GS
I think I got the answer by a twisted way.
I was stuck in vb, I went to C# got something the syntactically correct, get
the code fragment translated back to vb using online converter and here is
something VB will accept:

import Microsoft.Offic e.Interop

'Create a new workbook in Excel

'Create a new workbook in Excel
Dim oExcel As Microsoft.Offic e.Interop.Excel .Application
Dim oBook As Microsoft.Offic e.Interop.Excel .Workbook
oExcel = New Microsoft.Offic e.Interop.Excel .Application()
oBook = New Microsoft.Offic e.Interop.Excel .Workbook()

'Paste the data

Dim oSheet As Microsoft.Offic e.Interop.Excel .Worksheet
Dim oRange As Microsoft.Offic e.Interop.Excel .Range
oSheet = DirectCast(oBoo k.ActiveSheet,
Microsoft.Offic e.Interop.Excel .Worksheet)
' aha, the trick is to use directcast

oRange = oSheet.Range("A 1")
oSheet.Paste()
Jun 16 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3755
by: William Ryan | last post by:
In a nutshell, I need to get the name of the object that was just pressed (in this case, the object will be a radioButton). I want to write one handler for all four radio buttons and branch off depending on which one was clicked..I can get it to work if I take off Option Strict and use late Binding...but rather program an abacus than turn off Option Strict... here's my code Private Sub optFullTime_CheckedChanged(ByVal sender As...
3
6720
by: deko | last post by:
So I've decided to convert from Early Binding to Late Binding. Now that I've been baptized, I need some instruction in the faith. My former ways were thus: Dim xlapp As Excel.Application Set xlapp = CreateObject("Excel.Application") and then I went off in debauchery like this:
3
1438
by: Thomas Müller-Lynch | last post by:
How can I avoid late binding with the directive strict = tru My ASP .net-file looks like this <%@DEBUG=true TRACE=true Strict=false EXPLICIT=true% .. dim footerValues as Arra footerValues = split("val1,val2,val3,val4,val5", "," .. dim strDept as String = footerValues(0
3
2555
by: Lenonardo | last post by:
Can anyone tell me how I refer to Excel constants when using late binding. I've tried searching the Excel.application interface but can't find any reference in the hierarchy to an object that holds constants (such as XlPattern.XL.....). This must be possible (e.g. as with a typelib) but I can't track it down. Any help appreciated.
30
2834
by: lgbjr | last post by:
hi All, I've decided to use Options Strict ON in one of my apps and now I'm trying to fix a late binding issue. I have 5 integer arrays: dim IA1(500), IA2(500), IA3(500), IA4(500), IA5(500) as integer The integers in these arrays are actually pointers to different columns of data in a text file.
6
1248
by: active | last post by:
Me is a combobox and the items are objects with a property "String1" The problem with the following construct is that one does not know if there is a typo until run time. Me.Items(LpCnt).string1 What is the best way to force early binding or at least get the compiler to
6
3107
by: Stephany Young | last post by:
Using VS2005 and VB.NET and given a Windows Forms application with a single form (Form1) with 2 buttons (Button1 and Button2), I am attempting to instantiate an instance of Excel utilising late binding. The pertinent code is shown below. The business rules are: 1. If an instance of Excel is already running then use the equivalent of GetObject to obtain a reference to that instance, and, when finished, leave that instance running.
4
2614
by: =?Utf-8?B?Y2xhcmE=?= | last post by:
Hi all, what is the difference between the late binding and reflection? clara -- thank you so much for your help
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10214
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10048
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9996
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.