I can't figure out how to save a data table as a new worksheet in an excel file.
I can create the Excel file if it doesn't exist, but I can't seem to create a worksheet inside of it.
Here is what I have (sorry if it's a little sloppy):
ExcelFilePath = "C:\Temp\";
ExcelFileName = "WO " || "276" || " Summary.xls";
Path = ""||ExcelFilePath||""||ExcelFileName||"";
CurrentPart = "NewTab";
Try(
dtExistingFile = Open(""||Path||"");
Close(dtExistingFile, no save),
dtNewFile = New Table();
:Column 1<<Set Name("Counter");
dtNewFile<<Add Rows(1);
:Counter[1] = "Targets";
Close(dtNewFile, save(""||Path||"")),
);
dtOld = New Table();
:Column 1<<Set Name("Counter");
dtOld<<New Column("Run Wafer");
dtOld<<Add Rows(1);
:Counter[1] = "Target";
ExcPref = Char(Arg( Parse((Char( Get Preferences( Excel Selection ) )) ), 1 ) );
Set Preferences( Excel selection( 0 ) );
dtOld<<Save Database("DSN=Excel Files;DBC="||path||";Default Dir="||ExcelFilePath||";DriverID =
1046;MaxBufferSize=2048;PageTimeout=5;",CurrentPart);
Close(dtOld, no save);
Set Preferences( Excel selection( ExcPref ) );
I've looked over some info here but when I run it I get :
[Microsoft][ODBC Excel Driver] The Microsoft Access database engine cannot open or write to the file '(unknown)'. It is already opened exclusively by another user, or you need permission to view and write its data.
...in the log. I have double checked and there are no permission issues with the directory of file. Can anyone offer some advise?