Avatar of Me4o
Me4o

asked on 

Dumping excel sheet to an array

I am migrating a VBScript to a VB.net app.  The first line is the code I used in VBScript, but that doesnt work, and have tried the second one with no success.  

I get "Unable to cast COM object of type 'System.__ComObject' to class type 'System.Object[]'. Instances of types that represent COM components cannot be cast to types that do not represent COM components; however they can be cast to interfaces as long as the underlying COM component supports QueryInterface calls for the IID of the interface."
Set arrayraw1 = objWorksheet.Range(objWorksheet.Cells(1, 1), objWorksheet.Cells(worksheetnames(0,1), numcols))
 
 
Dim arrayraw1() As Array = objWorksheet.Range(objWorksheet.Cells(1, 1), objWorksheet.Cells(worksheetnames(0, 1), numcols))

Open in new window

Visual Basic.NET

Avatar of undefined
Last Comment
Wayne Taylor (webtubbs)
ASKER CERTIFIED SOLUTION
Avatar of Wayne Taylor (webtubbs)
Wayne Taylor (webtubbs)
Flag of Australia image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Me4o
Me4o

ASKER

Well, I feel like a complete idiot..  LOL..  I cant belive it was that simple...  LOL...  well...  thank you!
Avatar of Me4o
Me4o

ASKER

Thanks again..  I never thought about staying the .Value as I figured that was implied...
We all have moments like that ;-)

Glad I could help.

Wayne
Visual Basic.NET
Visual Basic.NET

Visual Basic .NET (VB.NET) is an object-oriented programming language implemented on the .NET framework, but also supported on other platforms such as Mono and Silverlight. Microsoft launched VB.NET as the successor to the Visual Basic language. Though it is similar in syntax to Visual Basic pre-2002, it is not the same technology,

96K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo