Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

setting seperate excel worksheet properties

Status
Not open for further replies.

rumman

Programmer
Feb 10, 2002
20
0
0
US
dear experts,

during printing reports using exel worksheet in a VB project,i faced the following problems.

1. i generated 2 reports,one in sheet 1 and other in sheet two, but i'm not able to set seperate properties for sheet1

for first sheet-----
range("A1:A4").select
With selection.font
.font.size = 9
end with
for second sheet-----
Appexel.sheets("sheet2").range("A1:A4").select

shows error:"selection method or range is invalid"
so how do i set the properties?


2.after generating the .xls file,if i generate it once again without closing the last generated one(book1.xls),the next file generated gets written over the last book1 and makes a mix of both old and new files

3.Once i generate the report seperately using radio buttons for each report,if close the file,clicking the control button X,and try to generate one more file,the whole application gets hung

please help me with ur suggestions

thank you for ur time
rumman
 
don't know much about controling excel from outside but you can't select a sheet and a range in the same statement
However, if you just want to change the properties, you're better off NOT selecting at all. You can change the properties without selecting eg
With appexcel.sheets("Sheet1").range("A1:A4")
.fontsize = 9
End With
With appexcel.sheets("Sheet2").range("A1:A4")
.fontsize = 10
End With

This will be quicker, especially if you have a lot of stuff to do

As to the other questions, it might be worth asking them in one of the VB forums

HTh
Geoff
 
consider this:

Range("Sheet1!A1:A4").Font.Size = 20
Range("Sheet2!B3:B5").Font.Size = 8
 
thank you for your time and effort,it works!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top