uses
.., ComObj;
var
ExcelObj: OleVariant;
objRange: OleVariant;
WorkBook: OleVariant;
WorkSheet: OleVariant;
begin
ExcelObj := CreateOleObject('Excel.Application');
ExcelObj.DisplayAlerts := False; //경고문구 해제
try
WorkBook := ExcelObj.Workbooks.Open('내용을 검색할 엑셀경로');
WorkSheet := Workbook.WorkSheets[1]; //Sheet 선택
WorkSheet.Activate; //선택한 Sheet 활성화
objRange := WorkSheet.Cells.Find(what := '검색내용');
//검색 파라미터 참조 -> https://docs.microsoft.com/en-us/office/vba/api/excel.range.find objRange.Select; //검색된 셀 선택
ExcelObj.Visible := True; //엑셀로 보여주기
except
on E: Exception do begin
ShowMessage(E.Message);
end;
end;
ExcelObj := unAssigned;
WorkBook := unAssigned;
WorkSheet := unAssigned;
end;
반응형