我对VBA非常陌生,具有VB.net的基本知识
我正在尝试创建一个excel宏,它将运行Winshuttle脚本以自动将产品引入SAP。截至目前,我们需要七个SAP事务来完成系统中产品的创建,因此我尝试使用Winshuttle自动执行每个事务,并将它们链接到Excel工作表中的七个宏按钮,以便任何人都可以使用单个程序运行它们单击。出于合规性原因,我确实需要将每个脚本分开,因此只需使用一个按钮就可以运行所有七个脚本。
Winshuttle提供了一个导出宏的选项,允许通过Excel调用脚本,我更改了基础知识,例如计算机中的脚本位置,startrow,endrow,logcolumn和runonrows值,但现在我得到了以下错误:
打开工作表时发生错误
对象引用未设置为对象的实例
有人可以帮忙吗?另外什么
'根据要求和文件的可访问性更改ALF路径。
'可以写入数据的更改表
意思?我应该在三行代码之前删除“'”并更改文件路径吗?是必要还是选择?
完整的代码如下:
'----------------------------------------------
' Macro to use runSHUTTLE addin with code
'----------------------------------------------
Sub RunSHUTTLEfile()
'
' RunSHUTTLEfile Macro
'
Dim runSHUTTLEAddin, AddinObject
On Error GoTo ErrHandler
' GET ADDIN OBJECT FROM EXCEL
Set runSHUTTLEAddin = Application.COMAddIns.Item("TxRunner.AddinModule")
If runSHUTTLEAddin Is Nothing Then
MsgBox "Unable to initialize object of runSHUTTLE addin"
Exit Sub
End If
' Get com object from addin object
Set AddinObject = runSHUTTLEAddin.Object.TsMacros
If runSHUTTLEAddin Is Nothing Then
MsgBox "Unable to initialize com object of runSHUTTLE addin"
Exit Sub
End If
' Set the type of run from the following
' RunNow = 0,
' RunOnErrors = 1,
' StepByStep_StopOnAllScreens = 2,
' StepByStep_StopOnErrors = 3
AddinObject.TypeofRun = 0
' Set the Run On Rows from the following
' AsInShuttleFile = 0, // rows as in SHUTTLE file
' Selected = 1, // selected rows on active excel sheet
' Filtered = 2 // filtered rows on active excel sheet
AddinObject.RunOnRows = 1
Dim strShuttleFile As String
' open existing SHUTTLEfile to Run
strShuttleFile = "C:\Users\310274697\Documents\WinShuttle\TRANSACTION\TRANSACTION scripts\Creation of Materials Scripts\2017.11.21 ZMM01U creation of materials BR9V.txr"
AddinObject.OpenShuttleFile (strShuttleFile)
AddinObject.StartRow = 2
AddinObject.EndRow = 3
AddinObject.LogColumn = "E"
'Change ALF path as per requirement and accessibility of file.
'Change Sheet where data can be written
'AddinObject.SheetName = "Sheet3"
'AddinObject.AlfPath = "C:\USERS\SASINGH\DOCUMENTS\WINSHUTTLE\TRANSACTION\ALF\WE6800_ANKUR.ALF"
'AddinObject.ResultFileName = "C:\Users\SASINGH\Documents\Winshuttle\TRANSACTION\Data\Copy of Abs-ldcvb.xlsx"
' Call the Run Function to start uploading data
AddinObject.Run
Exit Sub
ErrHandler:
MsgBox Err.Description
End Sub
答案 0 :(得分:0)
strShuttleFile =“C:\ Users \ 310274697 \ Documents \ WinShuttle \ TRANSACTION \ TRANSACTION scripts \ Materials of Scripts \ 2017.11.21 ZMM01U创建材料BR9V.txr” AddinObject.OpenShuttleFile(strShuttleFile)
“(strShuttleFile)”不应该在那里。消除了摆脱错误。
现在我看到“无效的程序调用或参数”,所以我花了几个小时来弄清楚这意味着什么。