我正在尝试使用 SAP ABAP OLE OBJECT 打开受密码保护的 excel 文件,如下所示:
DATA: lt_excel_line(4096) OCCURS 10 WITH HEADER LINE.
DATA: app TYPE ole2_object,
workbook TYPE ole2_object,
worksheet TYPE ole2_object.
CREATE OBJECT app 'EXCEL.APPLICATION'.
SET PROPERTY OF app 'VISIBLE' = 0.
CALL METHOD OF app 'WORKBOOKS' = workbook.
CALL METHOD OF workbook 'OPEN'
EXPORTING
#1 = '<filename>'
#5 = '<password>'.
文件名和密码绝对正确,下面的 VBA 代码按要求打开文件没问题:
Dim wb1 As Workbook
Set wb1 = Workbooks.Open Filename:="<filename>", Password:="<password>")
但是 ABAP 代码总是返回 sy-subrc = 2。有人知道会发生什么吗?或者我还能尝试什么?感谢任何帮助。