运行-时间错误 1004 - 找不到 BloombergUI
Run-time error 1004 - couldn't find BloombergUI
我是 运行 一个执行 VBScript 的批处理文件,该 VBScript 在彭博终端 Excel sheet 中运行一个宏。
excelsheet单元格中包含大量BDP公式。这些都很好用。最初,我在更新来自 Bloomberg 和 运行 宏的数据时遇到了问题,但是通过使用 bloombergui.xla.RefreshAllStaticData + 计时器解决了这个问题。
宏在 excel 中手动执行时运行完美,但我在尝试通过批处理和 VBS 自动执行时得到 "run-time error 1004 couldn't find bloombergui.xla..."。
有什么解决办法吗?我想我已经通过 google 穷尽了所有选项。
宏:
Sub UpdateWeekly()
Application.Run "bloombergUI.xla!RefreshAllStaticData"
Application.OnTime (Now + TimeValue("00:00:25")), "WeeklyPDF"
End Sub
Sub WeeklyPDF()
Application.ScreenUpdating = True
ActiveSheet.Range("A1:V225").Select
Selection.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="O:\LOCATION" & Format(Date, "MMMM-DD-YYYY") & " " & "Weekly", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Application.PrintCommunication = False
End Sub
VBScript:
Dim args, objExcel
Set args = WScript.Arguments
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open args(0)
objExcel.Visible = True
objExcel.Run "UpdateCreditWeekly"
objExcel.ActiveWorkbook.Close(0)
objExcel.Quit
我认为你的语法不正确。
Application.Run can be used to run a macro written in Visual Basic or
the Microsoft Excel macro language, or to run a function in a DLL or
XLL.
The macro you specify can be either a string with the macro name,
or a Range object indicating where the function is, or a
register ID for a registered DLL (XLL) function. If a string is
used, the string will be evaluated in the context of the active sheet.
此外,如果您使用的是 Excel 的较新版本,您将遇到更多问题,因为我认为 XLA
是一种较旧的文件类型,因为已被 XLAM
取代.
查看下面的链接了解更多信息,尤其是 this one and this one。
更多信息:
堆栈溢出:Run Excel Macro from Outside Excel Using VBScript From Command Line
堆栈溢出:How do I call an xll addin function from vba?
当 Excel 以编程方式实例化时,Bloomberg Add-in 无法加载...我认为您每次都需要重新加载它。
调用前确保加载项存在 Application.Run "bloombergUI.xla!RefreshAllStaticData"
Sub UpdateWeekly()
Dim blpAddin As Workbook
On Error Resume Next
Set blpAddin = Workbooks("bloombergUI.xla")
On Error GoTo 0
If Not blpAddin Is Nothing Then ' Check if add-in is loaded or not
Application.Run "bloombergUI.xla!RefreshAllStaticData" ' refresh Bloomberg formulas
Application.OnTime (Now + TimeValue("00:00:25")), "WeeklyPDF" ' wait till bloomberg Formulas calculation complete
Else
Debug.Print "Bloomberg Add-in is not loaded"
End If
End Sub
如果 Add-in 不存在,那么您需要 Add/load add-in
'To load the Add-in
Application.Addins.Add(file path & name)
或
AddIns("Add-In Name").Installed = True
我是 运行 一个执行 VBScript 的批处理文件,该 VBScript 在彭博终端 Excel sheet 中运行一个宏。
excelsheet单元格中包含大量BDP公式。这些都很好用。最初,我在更新来自 Bloomberg 和 运行 宏的数据时遇到了问题,但是通过使用 bloombergui.xla.RefreshAllStaticData + 计时器解决了这个问题。
宏在 excel 中手动执行时运行完美,但我在尝试通过批处理和 VBS 自动执行时得到 "run-time error 1004 couldn't find bloombergui.xla..."。
有什么解决办法吗?我想我已经通过 google 穷尽了所有选项。
宏:
Sub UpdateWeekly()
Application.Run "bloombergUI.xla!RefreshAllStaticData"
Application.OnTime (Now + TimeValue("00:00:25")), "WeeklyPDF"
End Sub
Sub WeeklyPDF()
Application.ScreenUpdating = True
ActiveSheet.Range("A1:V225").Select
Selection.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:="O:\LOCATION" & Format(Date, "MMMM-DD-YYYY") & " " & "Weekly", _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Application.PrintCommunication = False
End Sub
VBScript:
Dim args, objExcel
Set args = WScript.Arguments
Set objExcel = CreateObject("Excel.Application")
objExcel.Workbooks.Open args(0)
objExcel.Visible = True
objExcel.Run "UpdateCreditWeekly"
objExcel.ActiveWorkbook.Close(0)
objExcel.Quit
我认为你的语法不正确。
Application.Run can be used to run a macro written in Visual Basic or the Microsoft Excel macro language, or to run a function in a DLL or XLL.
The macro you specify can be either a string with the macro name, or a Range object indicating where the function is, or a register ID for a registered DLL (XLL) function. If a string is used, the string will be evaluated in the context of the active sheet.
此外,如果您使用的是 Excel 的较新版本,您将遇到更多问题,因为我认为 XLA
是一种较旧的文件类型,因为已被 XLAM
取代.
查看下面的链接了解更多信息,尤其是 this one and this one。
更多信息:
堆栈溢出:Run Excel Macro from Outside Excel Using VBScript From Command Line
堆栈溢出:How do I call an xll addin function from vba?
当 Excel 以编程方式实例化时,Bloomberg Add-in 无法加载...我认为您每次都需要重新加载它。
调用前确保加载项存在 Application.Run "bloombergUI.xla!RefreshAllStaticData"
Sub UpdateWeekly()
Dim blpAddin As Workbook
On Error Resume Next
Set blpAddin = Workbooks("bloombergUI.xla")
On Error GoTo 0
If Not blpAddin Is Nothing Then ' Check if add-in is loaded or not
Application.Run "bloombergUI.xla!RefreshAllStaticData" ' refresh Bloomberg formulas
Application.OnTime (Now + TimeValue("00:00:25")), "WeeklyPDF" ' wait till bloomberg Formulas calculation complete
Else
Debug.Print "Bloomberg Add-in is not loaded"
End If
End Sub
如果 Add-in 不存在,那么您需要 Add/load add-in
'To load the Add-in
Application.Addins.Add(file path & name)
或
AddIns("Add-In Name").Installed = True