简体   繁体   中英

Excel Runtime error 13

I've gone through various posts and can't figure out my problem.

I have a COM object that builds and a Excel.Range of data and hands this back to an Excel macro. This is then set to a Variant and then it's used to populate a range. Quite simple and it was working, but now it's not I can't figure out why.

The C# is passing back the correct data by setting the Variant, which is causing my error.

Any ideas?

The code is below:

Dim rangeData As Variant
rangeData = factory.Build(buildType)

Worksheets(sheet).Activate
Worksheets(sheet).range("A1:Z10000").Value = rangeData

The factory object is my C# COM object.

Your rangeData should probably be an array of Variants, if your COM object returns an array.

Try to declare rangeData like this (notice the brackets):

Dim rangeData() as Variant

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM