我能够连接到服务器上的SAP BW(业务仓库),以打开特定的查询,但最终还是无法保存。我尝试在各种论坛上进行搜索,但是它们都使用与我相同的逻辑。我正在使用CMD运行此脚本。
另一方面,我的系统抛出了一个错误:
对象不支持以下属性或方法:'SaveAs'
代码:800A01B6
' Setup the global variables
Dim xl
Dim myConnection
Dim xlBook
' Launch Excel
Set xl = CreateObject("Excel.Application")
' Make it visible otherwise things just don't work well
xl.Visible = True
' Now that Excel is open, open the BEX Analyzer Addin xla file
xl.Workbooks.Open ("C:\Program Files (x86)\Common Files\SAP Shared\BW\BExAnalyzer.xla")
' Run the SetStart macro that comes with BEX so it pays attention to you
xl.Run ("BExAnalyzer.xla!SetStart")
' Logon directly to BW using the sapBEXgetConnection macro
Set myConnection = xl.Run("BExAnalyzer.xla!sapBEXgetConnection")
With myConnection
.client = "100"
.User = "user"
.Password = "pass"
.Language = "EN"
.systemnumber = 00
.ApplicationServer = "xxxyyy"
.SAProuter = "xxxyyyyy"
.Logon 0, True
End With
' Now initialize the connection to make it actually usable
xl.Run ("BExAnalyzer.xla!sapBEXinitConnection")
' Open query
xl.Run "BExAnalyzer.xla!runQuery","00O2TPBVULP4LPJ4LBZRIFQN3"
' Initiate saving, turn off showing allerts
Application.DisplayAlerts = False
xl.SaveAs "C:\Output\NAME.xlsm"
'xl.SaveAs "C:\Output\NAME", 52 ' 52 should be the format for XLSM
Application.DisplayAlerts = True
'' Close Excel
'xl.Quit
我想将XLSM保存到特定文件夹。
答案 0 :(得分:1)
您的DispatchQueue.main.async {
// TODO: Your code
}
对象引用xl
对象。 Application
是SaveAs
对象的成员。设置对工作簿的引用,并使用它来执行保存操作
Workbook