A Microsoft Excel forum. ExcelBanter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » ExcelBanter forum » Excel Newsgroups » Excel Discussion (Misc queries)
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

how to declare local variables for Excel.Workbook at runtime.

Thread Tools Display Modes
Old October 9th 06, 12:19 PM posted to microsoft.public.excel.misc
external usenet poster
Posts: 13
Default how to declare local variables for Excel.Workbook at runtime.

Hi i want to how to declare local variables for Excel.Workbook object
at runtime using C#.

Suppose i have a dropdown which contains the list of excel files in a
Say there are 3 files in a particular folder. july.xls,
august.xls,september.xls. Each time the user selects a file i declare a
variable xlbook of type Excel.Workbook and open tat wbook.

Excel.Application xlApp=new Excel.Application();
xlbook1=xlApp.Workbooks.open("c:\\july.xls",missin g.value,missing.value....);
xlbook2=xlApp.Workbooks.open("c:\\august.xls",miss ing.value,missing.value..);
xlbook3=xlApp.Workbooks.open("c:\\september.xls",m issing.value,missing.value);

I want to know if i can declare xlbook1,xlbook2,xlbook3 at runtime...

Excel.Workbook xlBookN;


Where xlBookN=xlBook1,XlBook2...etc

If this is not possible i atleast want to declare a new local variable
for each of the excel file in the folder. like

Excel.Workbook a; Excel.Workbook b; Excel.Workbook monday; I just
want the name of the local variable to be unique for each
Excel.Workbook object that is created.

With Regards


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to efficiently declare variables Jeff Excel Discussion (Misc queries) 2 June 29th 06 01:56 PM

All times are GMT +1. The time now is 11:31 PM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright 2004-2017 ExcelBanter.
The comments are property of their posters.