Anyone have code to set margins(top,left,right,bottom) using excel interop and vb.net. I think it must be part of the worksheet object but maybe the workbook object. Having a tough time finding an example. Thanks in advance.
+1
A:
I found it its part of the worksheet object...
i.e.
xlWorkSheet.PageSetup.TopMargin=0.5
Nick LaMarca
2010-04-08 18:34:14
+1
A:
Margins are set through the PageSetup object which you get from on the WorkSheet.PageSetup property.
Charles
2010-04-08 18:35:24
Charles thats what I thought, but excel isnt taking it for some reason. My margins are not getting set in the output file
Nick LaMarca
2010-04-08 19:33:48
Don't know what your problem might be. I'm actually using SpreadSheetGear which wraps the Excel object model, so I don't use Excel classes directly. Maybe if you post the non-working code, someone will notice the problem.
Charles
2010-04-08 19:41:01
ws.PageSetup.Orentation=Excel.xlpageorentation.xlLandscapews.PageSetup.Zoom=Falsews.PageSetup.FitToPagesWide=1ws.PageSetup.FitToPagesTall=1ws.PageSetup.TopMargin=0.5ws.PageSetup.LeftMargin=0.25ws.PageSetup.RightMargin=0.25ws.PageSetup.BottomMargin=0ws.Protect()Disregard any typos I may have made. Everything is setting fine, but the margins
Nick LaMarca
2010-04-08 19:52:12
I meant add code to your question. :)
Charles
2010-04-08 20:23:05