Click to See Complete Forum and Search --> : Working with Excel
liorde
January 20th, 2000, 09:01 AM
Hi,
I would like to open an existing form of Excel and retreive information about it for example how many sheets, how many columns, rows etc..
How can this be done??
Thank-you!!
LED
Lothar Haensler
January 20th, 2000, 09:11 AM
to connect your program to a running instance of Excel use the GetObject function in VB.
Save the return value in an object variable and use Excel's object model to query it for all desired properties of all relevant objects.
Lothar Haensler
January 20th, 2000, 09:13 AM
sample code from MSDN.
Dim appXL As Excel.Application
Set appXL = GetObject(, "Excel.Application")
liorde
January 20th, 2000, 09:29 AM
Hello,
I need to know how to open an existing file for example c:\My Documents\abc.xls and if not exists then create it. Then I would like to run over it's sheets and columns and rows and modify / check what I need . Is there a code sample for this or an article in the MSDN disc?/
Thanks
LED
Lothar Haensler
January 20th, 2000, 10:08 AM
to open a file into excel, add a reference to the Excel typelibrary to your VB project and use the following code
Dim x as Excel.Application
Dim wb as Excel.Workbook
set x = CreateObject("Excel.Application")
set wb = x.Workbooks.Open("c:\test.txt")
x.Visible = true
' now to the modifications and queries
wb.Save ' save your modifications
set x = nothing
check out the Excel object model via the object browser in VB (F2)
liorde
January 23rd, 2000, 04:40 AM
Hi Lothar,
I need some more "specificness".
1. What is a "workbook" of an Excel application?
2. What does the method "CreateObject" do??
3. What is the Set x = nothing stand for??
4. What is F2 used for in this example?
5. How do I close the Excel application afetr finishing all modifications?
Thank-you again!!
LED
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.