Link to home
Start Free TrialLog in
Avatar of szx248
szx248

asked on

VB4 & Excel97/Excel 2000 ???

Here is my dilemma:

I have a VB4 application that manipulates an Excel 5 spreadsheet.

Now we are moving to Excel 97 (and very, very soon to Excel 2000).

When I install Excel 97 VB no longer works with Excel and returns an Error.

Any clue how to get this working with Excel 97/Excel 2000 w/o rewriting the whole application?

Thanks
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

What is the error that you are getting?  What does the code look like?
Avatar of szx248
szx248

ASKER

This is the code one which it chokes:
MyExcel.Cells(7 + t, 1).Value = DateAdd("yyyy", 1, DateAdd("m", t, CVDate(Text1)))

The Error message is 438
Object doesn't support this property or method
What is MyExcel dimensioned as?  How is it set?
Avatar of szx248

ASKER

Set MyExcel = GetObject(glocationdir & "client.xlt", "excel.sheet")
MyExcel.SaveAs filename:=myfile
MyExcel.Unprotect

MyExcel.Cells(7 + t, 1).Value = DateAdd("yyyy", 1, DateAdd("m", t, CVDate(Text1)))
With Excel97, you .Sheet has changed to .WorkSheet.

You could also do this:

Dim MyExcel As New Excel.Application
Dim MySheet As Excel.Worksheet

Set MySheet = MyExcel.Workbooks.Open(gLocationDir & "client.xlt")
Avatar of szx248

ASKER

Dim MyExcel As New Excel.Application

Here I get "Invalid use of New keyword" error message

If I remove it then I get an error on this line:

Set MySheet = MyExcel.Workbooks.Open(gLocationDir & "client.xlt")

Error 91
Object doesn't support this property or method
Where are you running this from?  VB or Excel?
Did you include a reference in your project for Microsoft Excel 8.0 Object Library?
Avatar of szx248

ASKER

running from vb

Avatar of szx248

ASKER

I am using VB4 and I don't see any Rerfernce to Microsoft Excel 8.0 Object Library
Is there a reference to any library that resembles Office or Excel?

I haven't used anything but Office 97 for quite a while so I can't remember what the references for other versions are.
ASKER CERTIFIED SOLUTION
Avatar of Bob Learned
Bob Learned
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of szx248

ASKER

At the end just adding
Worksheets("Client").

To
MyExcel.Cells(7 + t, 1).Value = DateAdd("yyyy", 1, DateAdd("m", t, CVDate(Text1)))

like this:
MyExcel.Worksheets("Client").Cells(7 + t, 1).Value = DateAdd("yyyy", 1, DateAdd("m", t, CVDate(Text1)))

Got it working.

let me know if u think there is something else I may be overlooking.

I am using VB4 with NO refrence to Excel 8.0 to the best that I can deturmine.

Thanks for pointing me in the right direction