Link to home
Start Free TrialLog in
Avatar of ilcapocamorra
ilcapocamorra

asked on

VisualBasical 2010 w/Excel 2007

Hi All,

I have a visual basic program that copies data from a text file puts it in a worksheet and makes a graph from the data.  For some reason the exe works fine on my machine but does not well on another.

Particularly it is failing on:
metricWorkbook.Worksheets(filename).copy(after:=XLSXWorkbook.Worksheets("Sheet1"))
        XLSXWorkbook.ActiveSheet.Name = MetricType


MetricType is defined as "PSNR"
filename as "DL1"

The issue is it works fine on all other machines except this one.  I do not see any dependencies except .net 4.0 which is installed. :(
Avatar of Zack Barresse
Zack Barresse
Flag of United States of America image

Is there possibly no "Sheet1"?  Probably not a good idea to hardcode that value in there.  If it's the first worksheet you should use the index (1).  If it's a worksheet other than a newly created workbook, or you don't for sure know it's the first (left-most) worksheet you want to work with, you should probably set the worksheet as a variable first.

Regards,
Zack Barresse
Avatar of ilcapocamorra
ilcapocamorra

ASKER

Hi Zack, thanks for the feedback, so something like:

metricWorkbook.Worksheets(filename).copy(after:=XLSXWorkbook.Worksheets(index(1)))

Thanks!
ASKER CERTIFIED SOLUTION
Avatar of Zack Barresse
Zack Barresse
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
it seems to be an environmental issue:
Does the target machine has Excel 2007 installed?
If so:
Are the Excel 2007 service pack/updates the same on all machines?
How are you interfacing to Excel? (Interop, open xml)
Is th user opening the target workbook?