开发者

Is it possible to add reference to a version of Excel if it's not currently installed?

Using Visual Basic 2008 Express Edition

2 PCs are involved:

PC1 has VBEE and Excel 2007 installed

PC2 (target machine) does not have VBEE installed, and has Excel 2000

What I am trying to accomplish is to build an app on PC1 to use on PC2.

Of course, when I reference the 12.0 library during the build and then try to run using 9.0 on the target machine, I get a "can't find 12.0 object library" message. Also, I can't use late binding (as shown below): PC2's security settings apparently prohibit this...

    Dim objExcel As Object 'Excel.Application
    Dim objWB As Object 'Excel.Workbook
    Dim objWS As Object 'Excel开发者_如何转开发.Worksheet
    Dim objRng As Object 'Excel.Range

    Try
        'Try to Open Excel, Add a workbook and worksheet
        objExcel = CreateObject("Excel.Application") 'New Excel.Application

    etc...

So, is there any way to add reference to Excel 9.0 without it actually being installed on the same machine as VBEE?

Is there any other way around this?


Sure, I do that all the time. You'll need to grab the TLBs (or the main EXE or DLL that you have to reference) from the machine with the older version, copy IT to your dev machine (preferably somewhere in your project so you can put it under VCS, cause it just because part of the source of your project, and then set your references to that dll.

I've successfully done this with Word, Excel, PPT, and Outlook, coding against an addin that had to run in everything from Office 2000 through 2010.

I grabbed all the relevant TLBs and DLLs that contained the TLBs from various machines, located them centrally, and referenced those copies.

With .NET, you can even simultaneously reference several WORD tlbs (though I didn't have any need to actually do it). With VB6, you can't really take it that far, but again, you generally shouldn't need to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜