Name errors with excel addin loaded through VBScript

solitude

New Member
Joined
Aug 16, 2011
Messages
11
I'm trying to run some excel macros through VBScript. The code also uses Bloomberg addin. Now, I know that VBScript by default switches addins off so in the script I have lines that add Bloomberg addin.

Problem is - while debugging, I get 'NAME' errors in cells that use Bloomberg functions. Though when I go to each cell and do "F2+Enter", it works and I get the desired values. The Bloomberg functions even appear in a drop-down when I go to a cell and start typing a formula. So, I'm not sure what's wrong.

The code I'm using is this -
Code:
Dim xlApp
Dim bbgAddin
set xlApp = CreateObject("Excel.Application")
Set bbgAddin = xlApp.AddIns.Add("path to bloomberg addin")
xlApp.Addins("Bloomberg Excel Tool").Installed = False    ' Need addin's name here
xlApp.Addins("Bloomberg Excel Tool").Installed = True

I'm using Excel 2007 on Windows Xp (shared terminal).
Any help is much appreciated.
 
Here is my vbscript code:
'It starts here
Dim strWorkerWB
strWorkerWB = "C:\swaps\swapok2.xls"
strWorkerWB2="c:\blp\API\Office Tools\BloombergUI.xla"

Dim strMacroName
strMacroName = "swapmakro"

' Create an Excel instance
Dim myExcelWorker
Set myExcelWorker = CreateObject("Excel.Application")

myExcelWorker.Visible=True

myExcelWorker.Workbooks.Open (strWorkerWB2)

' Disable Excel UI elements

myExcelWorker.DisplayAlerts = False
myExcelWorker.AskToUpdateLinks = False
myExcelWorker.AlertBeforeOverwriting = False
myExcelWorker.FeatureInstall = msoFeatureInstallNone

Dim StrPathNameNew

' Open the Workbook specified on the command-line
Dim oWorkBook

Set oWorkBook = myExcelWorker.Workbooks.Open(strWorkerWB )

'on error resume next
' Run the calculation macro
myExcelWorker.Run strMacroName
if err.number <> 0 Then
' Error occurred - just close it down.
End If
err.clear
on error goto 0

StrPathNameNew = replace(ucase(strWorkerWB),".XLS","") & "_" & year(Date()) & right("0" & month(date()),2) & right("0" & day(date()),2)& cstr(right(now,5)) & ".XLS"
oWorkBook.SaveAs StrPathNameNew
oWorkBook.Close

' Clean up and shut down
Set oWorkBook = Nothing

' Don’t Quit() Excel if there are other Excel instances
' running, Quit() will shut those down also
if myExcelWorker.Workbooks.Count = 0 Then
myExcelWorker.Quit
End If

Set myExcelWorker = Nothing
'It ends here

Here is my swapmakro procedure in the swapok2.xls:
'It start here
Sub swapmakro()
'Application.Run "RefreshEntireWorksheet"
Application.Run "RefreshAllStaticData"
Application.Wait DateAdd("s", 20, Now)
Range("A2:M5").Select
Selection.Copy
ActiveWindow.ScrollColumn = 2
ActiveWindow.ScrollColumn = 1
Range("A15").Select
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
:=False, Transpose:=False
End Sub
'It ends here


Why does it not stop recalculating the BDP function?
 
Upvote 0

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,224,603
Messages
6,179,849
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top