XP compatability problem???
Hi,
Using VB6 with SP6 I have written some software that accesses an excel file. I have compiled and run it on two computers that are on Windows 2000 and it works fine, although they both do have VB6 installed so I don't know the relevance of that.
The problem comes when I run it on XP (tried 2 seperate PCs) . I get an invalid page error come up at this point of the program...
##############################################
Dim xlApp As Excel.Application
Dim wb As Workbook
Dim ws As Worksheet
Dim var As Variant
Set xlApp = New Excel.Application
Set wb = xlApp.Workbooks.Open("c:\dump\" & txt_jn & ".xls")
Set ws = wb.Worksheets("Sheet1")
##############################################
Obviously the relevant folders and files are in place on the PC.
I am referencing "C:\Program Files\Microsoft Office\Office10\excel.exe" but I note that on the pc with XP it is in fact C:\Program Files\Microsoft Office\Office\excel.exe.
Is this the likely cause and if so what can I do to get around this?
Re: XP compatability problem???
Its not good to reference Excel (or office apps) when the versions could be different.
Remove the reference, and change it to
Dim xlApp as Object
Set xlApp = CreateObject("Excel.Application")
now, you need to go thru your code and find any Excel Constanst and replace them with the value... so like
xlThick = 2
xlAutomatic = -4142 (I think)
stuff like that, since VB will no longer know what the values are..
understand?
Re: XP compatability problem???
There is a longer version of Static's explanation (and a link to a module which contains all of the contsants) in my Excel Tutorial (link in my signature).
Re: XP compatability problem???
u built a module with all the constants!??.. sweet.
[EDIT] ahh.. is see MS did it.. still, nice find[/EDIT]