Hi,
I have the following piece of working Perl code I'd like to convert to VBA
use Win32::OLE;
my $Broker = Win32::OLE->new('Broker.Application');
my $Stocks = $Broker->{Stocks};
my $ticker = "IBM";
if ($Stocks->Item($ticker)) {
$Stocks->Item($ticker)->{FullName} = "INTERNATIONAL BUSINESS MACHINES";
$Stocks->Item($ticker)->{IndustryID} = 2;
}
"Broker. Application" is the Stock Charting Package Amibroker. It's object model is at http://www.amibroker.com/guide/objects.html
Stocks is a collection with methods Add Item and Remove. The key to Stocks is string like "IBM" for example
In VBA I've coded
Set Amibroker = CreateObject("Broker.Application")
Set Stocks = Amibroker.Stocks
strTicker = "ABC"
If Stocks.Item(strTicker) = True Then
Stocks.Item($ticker).FullName = "ABC COMPANY";
Stocks.Item($ticker).IndustryID = 2;
End If
But I get Runtime error 91 Object variable or with block not set on the line
If Stocks.Item(strTicker) = True Then
Any help appreciated.
Thanks,
Geoff