VB.NET

Please post any questions regarding the program here.

Moderator: 2020vision

VB.NET

Postby Mitch » Mon May 07, 2007 2:48 am

From reading other threads here I get the impression that a fair few people have experience of computer languages. I'm having a bash at VB using Visual Studio Express and could use some help if possible.

I have some info from another website that I'd like to put into my Excel sheet that I use with BA. I've googled, searched, and asked on another forum without success about how to automate an existing workbook.
I've managed to create a new instance of Excel with a new workbook and use that, but can't find out how to use a workbook that's already open.

Any suggestions?
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester

Postby PeteB » Mon May 07, 2007 9:20 am

If you have create an instance of Excel and a new workbook, you are mostly there

Is the workbook already open in Excel, or will you need to search for it on the drive?

If it is open, the Excel.Application object should have a property Workbooks, and this should have a property / method like item or GetItem() - have a look at the help for that - you should be able to pass the name of the workbook in as a String.
If you are opening it from the drive it will be a bit more fiddly - can't remember how just now...
PeteB
 
Posts: 258
Joined: Tue May 23, 2006 12:13 pm

Postby GaryRussell » Mon May 07, 2007 11:05 am

The code I use in BA to automate Excel uses the following function to get an existing instance of Excel.

xl = GetObject(, "Excel.Application")
wb = xl.Workbooks(1) 'first workbook
ws = wb.Worksheets(1) 'first worksheet in workbook 1

Note that the workbooks and worksheets start at index 1, not 0
User avatar
GaryRussell
Site Admin
 
Posts: 9868
Joined: Fri Nov 18, 2005 8:09 pm
Location: Birmingham, UK

Postby Mitch » Mon May 07, 2007 11:26 am

PeteB wrote:If you have create an instance of Excel and a new workbook, you are mostly there

Is the workbook already open in Excel, or will you need to search for it on the drive?

If it is open, the Excel.Application object should have a property Workbooks, and this should have a property / method like item or GetItem() - have a look at the help for that - you should be able to pass the name of the workbook in as a String.
If you are opening it from the drive it will be a bit more fiddly - can't remember how just now...


The workbook is already open in Excel, and has BA linked to it. I want to put the info I've got alongside the info BA sends to it.
I'll have a search for GetItem(). Thanks Pete.
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester

Postby Mitch » Mon May 07, 2007 11:28 am

GaryRussell wrote:The code I use in BA to automate Excel uses the following function to get an existing instance of Excel.

xl = GetObject(, "Excel.Application")
wb = xl.Workbooks(1) 'first workbook
ws = wb.Worksheets(1) 'first worksheet in workbook 1

Note that the workbooks and worksheets start at index 1, not 0


I did try replacing CreateObject in the code I had working with GetObject, but it didn't work at the time so I guess I did something else wrong. I'll have another play with it.
Thanks for the hint Gary.
User avatar
Mitch
 
Posts: 365
Joined: Sat Nov 19, 2005 12:28 am
Location: Leicester


Return to Help

Who is online

Users browsing this forum: No registered users and 20 guests

Sports betting software from Gruss Software


The strength of Gruss Software is that it’s been designed by one of you, a frustrated sports punter, and then developed by listening to dozens of like-minded enthusiasts.

Gruss is owned and run by brothers Gary and Mark Russell. Gary discovered Betfair in 2004 and soon realised that using bespoke software to place bets was much more efficient than merely placing them through the website.

Gary built his own software and then enhanced its features after trialling it through other Betfair users and reacting to their improvement ideas, something that still happens today.

He started making a small monthly charge so he could work on it full-time and then recruited Mark to help develop the products and Gruss Software was born.

We think it’s the best of its kind and so do a lot of our customers. But you can never stand still in this game and we’ll continue to improve the software if any more great ideas emerge.