excel print papersize in VB.net

VBInfinite

Member
Joined
Feb 28, 2005
Messages
6
Location
Arlington, VA
Coder,

Im working on vb.net app that I want to do the following and hoping members can guide me to right direction. I want my program to be able to go to each excel files and expand the cell columns and if I click on 11 x 17, then my app will change excel print size to 11 x 17. Any idea? :confused: Thank you in advance

all comments are welcome. :p
 
Well, changing the Worksheets column width would look something like this:
Code:
Dim xlWS As Worksheet = CType(xlApp.ActiveSheet, Excel.Worksheet)
xlWS.Columns("A:C").ColumnWidth = 20
Ive never changed the print settings to 11x17, but I guess it would look something like this:
Code:
xlWS.PaperSize = Excel.XlPaperSize.xlPaper11x17
Hope this helps...

-- Mike
 
Sorry, it looks like I forgot a cast in the above. Try this when you get home:
Code:
Dim xlWS As Excel.Worksheet = CType(xlApp.ActiveSheet, Excel.Worksheet)
CType(xlWS.Columns("A:C"), Excel.Range).ColumnWidth = 20
-- Mike
 
Back
Top