Click to See Complete Forum and Search --> : Excel and VB


guptakvn
August 31st, 2001, 12:48 AM
Dear Gurus,
I am using Excel2000 for printing reports of an Visualbasic application. I have included the references (excel5.0 reference)in my project. I am not able to get the properties like
.cells(1,1).width and so on. I am able to access the cell and enter data into it. But not the width property or the font property of the cell and so on. What else should i include.

The other problem is :
I am showingthe excel worksheet when a button is clicked. by using xlsheet.application.visible=true . after the application is closed and i click the button again excel is unable to show the sheet.
in the click event i have added the code like
set xlsheet = xlbook.worksheets.add
Please clarify urgently.

Thank you.

Cimperiali
August 31st, 2001, 02:41 AM
You should add a reference to
microsoft excel 9.0 object library

About the sheet matter, this may help:

private Sub Command2_Click()
'xlapp and xlSheet are declared in general section of form as
'private withevents xlApp as Excel.Application
'private withevents xlSheet as Excel.Worksheet

If Not xlApp.ActiveWorkbook is nothing then
If xlApp.Worksheets.Count = 0 then
'it should never happens. It is here only
'to handle error situations
set xlSheet = xlApp.Worksheets.Add
else
set xlSheet = xlApp.Worksheets(1)
End If
else
'this should be your case:
xlApp.Workbooks.Add
set xlSheet = xlApp.Worksheets.Add
End If
End Sub




Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood, TCartwright, Bruno Paris, Dr_Micahel
and all the other wonderful people who made and make Codeguru a great place.
Come back soon, you Gurus.

The Rater