|
샘플로 짠 프로그램에서는 정상적으로 돌아가나..
설비 프로그램에서 실행시키면 에러가 납니다.
<코드>
// Grid 초기화
strGrid->Cells[0][0] = "No"; // [행, 열]
strGrid->Cells[1][0] = "발생시간";
strGrid->Cells[2][0] = "에러코드";
strGrid->Cells[3][0] = "에러내용";
for (int i = 1; i < strGrid->RowCount; i++)
strGrid->Cells[0][i] = IntToStr(i);
InErrIdx = 0;
// Alarm Excel File 오늘날짜로 불러오기
AnsiString ADate = FormatDateTime("YYYYMMDD", Now());
Variant XLApp, XLSheets, XLSheet, XLBooks, XLBook, VCell;
//AnsiString ADate = FormatDateTime("YYYYMMDD", Now());
AnsiString stFile = gStAppPath + "\\ALARM\\ERROR_" + ADate + ".xls";
if (FileExists(stFile)) { // 파일이 존재하면 읽어오기
XLApp = CreateOleObject("Excel.Application"); --------> 실행파일 로딩 성공
XLApp.OlePropertyGet("Workbooks").OleProcedure("Open", stFile.c_str()); ------> 여기서 에러
XLBook = XLApp.OlePropertyGet("ActiveWorkBook");
XLSheet = XLBook.OlePropertyGet("ActiveSheet");//엑티브sheet
//row갯수
int row = XLSheet.OlePropertyGet("UsedRange").OlePropertyGet("Rows").OlePropertyGet("Count");
//col갯수
int col = XLSheet.OlePropertyGet("UsedRange").OlePropertyGet("Columns").OlePropertyGet("Count");
strGrid->RowCount = row + 1;
strGrid->ColCount = col;
for(int j = 1; j < row; j++){
for(int i = 1; i < col; i++){
strGrid->Cells[i][j] = XLSheet.OlePropertyGet("Cells", j + 1, i + 1).OlePropertyGet("Value");
strGrid->Cells[0][j] = IntToStr(j);
}
}
XLBook.OleFunction("Close", (Variant)false);
XLApp.OleProcedure("Quit");
}
에러 메시지 내용은 다음과 같습니다.
Project 파일명.exe raised exception class EAccessViolation with message 'Access violation at address
0053F633 in module '파일명.exe'. Read of address 00000800'. Process ....
제발 도와주십시요. 부족한 내용 말씀해주시면 바로 수정해서 재업하겠습니다.
|