December 2007

Com Exception Error when Automating Excel from VB.Net

UPDATE!
hueymanchew, quite rightly points out that .text is read only, so the you can’t write to that property of a cell! A case of not seeing the wood for the tree I think!

I’m writing a light wight class to use in VB.Net projects which will late bind to Excel and dump a load of data into a worksheet or two. I want to late bind to avoid having to worry about which Interop Assemblies to use. Now with liberal use of “Object” decelerations it all work ok – sort of.
One strange thing is the fact that range(x).Text throws a wobbely, but that range(x).value is ok, probably something to do with whats the default? I’ve not seen this when automating with an early bound object and a “proper” PIA.

Code:
CodeWindow.PNG

Error:
ErrorMessage.png

Anyone else seen this – know what’s going on?

Free VBA code library!!!

Right that should get a few people here!

XL Dennis has made public the first version of his code librarian – “.NET Co Library”.
I’ve done a bit of testing for this addin and can personally vouch for how useful it is – keep all you VBA code in one place – copy the .mdb and take it with you, bung the .mdb on a network drive and you can share your code with the world (well the folks with access to the network any road)

Here’s what Dennis has to say:

.NET Co Library is a managed COM add-in for Microsoft Excel. The acronym Co in its name refers to both Connection and Code.

With the tool you can:

Store created VBA code, code snippets / procedures / modules, and SQL Queries in a well organized way enabling you to reuse the code in all kind of Excel VBA solutions.

Create connection strings to a various number of databases with two wizards, the .NET Wizard and the Data Link Wizard. Store the created connection strings in a structural way enabling you to reuse the connection strings in all kind of Excel VBA solutions.

.NET Co Library has been designed so it can be shared by a group of VBA developers over a network.

Thats right, it’s the future, it’s .Net!!!

The addin, makes it easy to save code snippets, (even whole modules) and search back through them in other projects – it’s a much better way to work with code than just copying it out of other workbooks…

xlCo1.png

But it’s not just VBA code, it’s SQL, and connection strings too…

xlCo2.png

What more could a Excel programmer ask for? Go on give it a try! And did i mention it was free…

more here:

Delphi needs a Dot Net?

Last night I downloaded Turbo Delphi, tonight I installed it, well, I tried to install it!

TurboDelphi.PNG

Looks like good old Delphi uses some parts of the .Net Framework and SKD – and why not really, but a little bit surprising?
Clearly I don’t have 1.1 – so I’ll have to install this in a few weeks(when time allows), at which point I’ll tell you want I think of it – I bet you can’t wait!