By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,290 Members | 1,195 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,290 IT Pros & Developers. It's quick & easy.

Option Strict On disallows late binding.

P: n/a
Hi all,

I use VB.net 2003 and want to export data to Excel. Target PCs still
have Office 2000 so I could not use Microsofts PIAs. Instead I use the
included Excel 10 COM DLL from Microsoft. Everything works fine.

Now I want to sign my application with a strong name. Therefore I also
need to sign all DLLs. So I searched through the web and found
information that I need to use tlbimp, and the source file is
'xl5en32.olb'. Now this also works fine.

But then I want to set options strict ON and I only receive this
error:
Option Strict On disallows late binding.

I've found that I need to use DirectCast but this does not seem to
work :-( Is there any documentation about exporting data to excel
while using strong names and option strict on?
Dec 16 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Heinz wrote:
Hi all,

I use VB.net 2003 and want to export data to Excel. Target PCs still
have Office 2000 so I could not use Microsofts PIAs. Instead I use the
included Excel 10 COM DLL from Microsoft. Everything works fine.

Now I want to sign my application with a strong name. Therefore I also
need to sign all DLLs. So I searched through the web and found
information that I need to use tlbimp, and the source file is
'xl5en32.olb'. Now this also works fine.

But then I want to set options strict ON and I only receive this
error:
Option Strict On disallows late binding.

I've found that I need to use DirectCast but this does not seem to
work :-( Is there any documentation about exporting data to excel
while using strong names and option strict on?


In what code does DirectCast not work? CType() is another less strict
version of directcast, it may solve your problem.

Chris
Dec 16 '05 #2

P: n/a
"Heinz" <He***********@NoSpam.de> wrote in message
news:2g********************************@4ax.com...
But then I want to set options strict ON and I only receive this
error:
Option Strict On disallows late binding.

I've found that I need to use DirectCast but this does not seem to
work :-( Is there any documentation about exporting data to excel
while using strong names and option strict on?


I've skirted this issue by moving my Excel late binding stuff into a
separate class files that has Option Strict Off.

I have code like this (see below), that I have not figured out yet how to
use Option Strict On w/ DirectCast. :(

Dim objSheet As Excel.Worksheet
....
objSheet.Cells(i, j).NumberFormat = "@" 'Option Strict On disallows late
binding error here

I'm interested in hearing others ideas as well.

Greg
Dec 16 '05 #3

P: n/a
"Greg Burns" <bl*******@newsgroups.nospam> wrote in message
news:uw*************@tk2msftngp13.phx.gbl...
I have code like this (see below), that I have not figured out yet how to
use Option Strict On w/ DirectCast. :(

Dim objSheet As Excel.Worksheet
...
objSheet.Cells(i, j).NumberFormat = "@" 'Option Strict On disallows late
binding error here


Nevermind...

DirectCast(objSheet.Cells(i, j), Excel.Range).NumberFormat = "@"

That does seems to be what I needed to allow Option Strict On. :)

Greg
Dec 16 '05 #4

P: n/a
On Fri, 16 Dec 2005 09:52:48 -0500, Chris <no@spam.com> wrote:
In what code does DirectCast not work? CType() is another less strict
version of directcast, it may solve your problem.


Hi Chris,

so I now modified my code and could save it even with options strict
on. But the export does not work.

I've now added the following code:

Dim XLApplication As Excel.Application
Dim XLWorkbook As Excel.Workbook
Dim XLworkbooks As Excel.Workbooks
XLApplication = CType(CreateObject("Excel.Application"),
Excel.Application)
XLworkbooks = DirectCast(XLApplication.Workbooks, Excel.Workbooks)
XLWorkbook = DirectCast(XLworkbooks.Add, Excel.Workbook)

Application crashes on second executed statement 'XLWorkbooks = ....'
with Error message 'Member not found'.....?? (Same if I use CTYPE
instead of DirectCast) So I'm also not sure whether it was correct to
sign the specified .olb file and use this one then...
Dec 19 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.