Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Programming in VB6 without Excel installed 1

Status
Not open for further replies.

windows98

Programmer
Nov 3, 1999
39
AU
I have written a program in VB6 using extensively Excel Workbooks and Worksheets and this is packaged by MS PWD. The program runs well on all machines which have MS Office installed but will not run on machines without Excel installed giving Runtime "Error 429 Activex component can't create object".
This also raises a question how should you proceed if you wished to write a VB6 program on a machine without Excel installed but wishing to use it extensively.
Please help
Henry



Henry Drillich
drillich@tpgi.com.au

 
I assume that your P&D install project has included "Microsoft Excel xx Object Library" in the install.

The Excel Viewer is a free download from Microsoft for machines that don't have Excel. It lets you view and print an Excel document.
 
You program for MS-Office on a machine that doesn't have it by instantiating the objects using CreateObject rather than setting a reference and instantiating them directly.

This makes developing lots tougher, as you don't get intellisense to help you out. So what you can do is develop with Office installed, then change your code to create your Office objects via CreateObject once you know it's working.

Chip H.


If you want to get the best response to a question, please check out FAQ222-2244 first
 
Dear Golom,
The package includes runtime version of Excel and all necesary References and Components.
Following Chip H.'s suggestion I will try to replace Set statements with CreateObject and see what happens. Thanks and regards,
Henry


Henry Drillich
drillich@tpgi.com.au

 
Dear Chip,
Thanks for your advice. I will try to replace Set statements with CreateObject and hope it will work. Regards,
Henry


Henry Drillich
drillich@tpgi.com.au

 
As far as I am aware (unless something has changed) you CANNOT use the Excel object library on a machine with-out a licensed version of Excel.
When I say "use", I mean legally.
You are not even allowed to re-distribute the Excel Object library or any of it's run-time libraries.

The only two methods which I am aware of, is:

1. You can access the Excel data on the worksheets by using JET.

2. You use the MS Office Developer's Kit, or however it's called, but it will cost you.
 
windows98

Can you clarify what you mean by
windows98 said:
The package includes runtime version of Excel and all necesary References and Components

The only Runtime for Excel that I know of is the viewer, which has no functionality associated.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Hopefully it is a mis-understanding.
Otherwise, this may be (unavoidably) ruining someone's day - or year.
 
Dear LostIn Code,
Runtime version means that only the VB program can acess this Excel functionality. You cannot open it and use outside the program.Regards,
Henry


Henry Drillich
drillich@tpgi.com.au

 
Dear johnwm

Runtime version means that only the VB program can acess this Excel functionality. You cannot open it and use outside the program.Regards,
Henry






Henry Drillich
drillich@tpgi.com.au

 
Dear windows98,

I think johnwm knows what a runtime library might be; the point he was gently trying to make is that he (and I and, I suspect, one or two others) is not aware of such a library (as described by you) for Excel.
 
Dear strongm,
Excel.exe can be packaged by PWD Wizard by Adding it to your packaged files; it becomes available only to VB program which is calling it.
Regards,
Henry



Henry Drillich
drillich@tpgi.com.au

 
To All,
My problem still persists.
I used CreateObject to enable OLE Automation and to assign it to an Object Variable.
I used GetObject to open a file.
I used Set to select a Worksheet (direct selection does not work gives Error 438).
The action on the first Worksheet worked OK.
When I wanted to select the Worksheet(2) problem re-appears in in Error 438.
To illustrate the problem here is a part of the code:
Public AppExcel As Excel.Application
Public MyObject As Object
Public Workbooks As Object

Private Sub cmdStart_Click()

Set AppExcel = CreateObject("Excel.Application") ‘ Creates OLE Automation object and assigns the object to an object variable

Set MyObject = AppExcel
reg = 0
Stat = 0

‘Opens OK the file if the file exists

Set MyObject = GetObject("c:\Program Files\CommonFiles\System\xyz.xls")
‘ The following Selects Worksheet 1 note
Set MyObject = MyObject.Worksheets(1)

‘Works OK if you have the file xyz

If MyObject.Cells(3, 1).Value = Empty Or MyObject.Cells(3, 1).Value = " " Then
ki = 0
MyObject.Cells(3, 1).Formula = 0
Else
ki = MyObject.Cells(3, 1).Value
End If
If MyObject.Cells(3, 2).Value = Empty Or MyObject.Cells(3, 2).Value = " " Then
di = 0
MyObject.Cells(3, 2).Formula = 0
Else
di = MyObject.Cells(3, 2).Value
End If
‘PROBLEM Selecting Worksheet 2 brings Error 438 "Object does not support this method or property"
Set MyObject = MyObject.Worksheets(2) or
MyObject.Worksheets(2).Select etc.

Any suggestions?
Regards,
Henry





Henry Drillich
drillich@tpgi.com.au

 
windows98

excel.exe is not a runtime version, and as far as I know it is not licensed for redistribution

The issue that we are all raising is not about what will work, but what is legal. Can you please provide a reference for the legality of redistributing this?

If not, see faq222-2244 paragraph 4. Members of Tek-Tips will not condone or assist in piracy or hacking

Please clarify the position for us.

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
As johnwm says, the fact that you can package excel with VB does not:

a) make it a runtime, only available to VB library
b) mean you have any right whatsoever to distribute it. That is breaking the terms of your Excel licence, and illegal

Which is what we have been trying to tell you gently all the way through this thread. Please take heed.
 
To All,
I am at fault trying to do what cannot (and now I believe should not ) be done. I will contact Microsoft regarding the way to provide from VB restricted Excel functionality for users who do not have Excel.
Incidentally Microsoft is protected because Error 429 denies Automation if Excel is not present.
Thanks for your guidance.
Regards,
Henry


Henry Drillich
drillich@tpgi.com.au

 
To All,
According to Microsoft I need Visual Studio Tools for Office,which works only with Office 2003 Professional.In the meantime I deleted Excel.exe from my package and the the program works OK provided the computer has Excel installed.
LostinCode was correct.Thanks to All for your help. Regards,
Henry


Henry Drillich
drillich@tpgi.com.au

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top