掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
Delphi8でExcelのRangeのEndプロパティを使うには? (ID:10986)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
Delphi8でExcel操作をする処理で、特定の列の最後の行を取得するために、RangeオブジェクトのEndプロパティを使用するとコンパイル時に下記のエラーが発生してしまいます。どなたか回避方法をご存知ないでしょうか? [エラー] unitMain.pas(230): 識別子 が必要な場所に 'END' があります 【参考ソース】 function Xls(fnm); var j,maxRow: integer; ExcelApp : Excel._Application; ExcelWorkBook : Excel._Workbook; ExcelSheets : Excel.sheets; ExcelSheet : Excel._Worksheet; begin ExcelApp := Excel.ApplicationClass.Create; ExcelWorkBook := ExcelApp.Workbooks.Open(fnm, Missing.Value,Missing.Value, Missing.Value,Missing.Value,Missing.Value, Missing.Value,Missing.Value,Missing.Value, Missing.Value,Missing.Value,Missing.Value, Missing.Value); ExcelSheets := ExcelWorkBook.sheets; try for j:=1 to ExcelSheets.Count do begin ExcelSheet := ExcelSheets[TObject(j)]; ExcelSheet.Activate; //A列の最後の行を取得 //(EndプロパティがDelphi8はコンパイルエラーになってしまう・・・) maxRow := ExcelSheet.Range[TObject('A65535'), Missing.Value].End[Excel.XlDirection.xlUp].Row; end; ExcelWorkBook.Saved := True; finally ExcelApp.Quit; ExcelApp := unAssigned; ExcelWorkBook := unAssigned; ExcelSheets := unAssigned; ExcelSheet := unAssigned; end; end;
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.