Balamurugan P

Balamurugan P

  • NA
  • 1
  • 3.5k

I Want To Convert the VBA Code to VB.Net Code for Setting the Print Area in Excel

Jan 27 2012 1:30 AM
Here the VBA Code for Setting the Excel Print Area [ A4 Size ].

Note: Below is the Print Macro Visual Basic Editor Code

Sub Macro3()
'
' Macro3 Macro
' Macro Recorded
'
'
  I = Cells(1, 19)
 
  Range(I).Select
Selection.Borders(xlDiagonalDown).LineStyle = xlNone
  Selection.Borders(xlDiagonalUp).LineStyle = xlNone
  With Selection.Borders(xlEdgeLeft)
  .LineStyle = xlContinuous
  .Weight = xlMedium
  .ColorIndex = xlAutomatic
  End With
  With Selection.Borders(xlEdgeTop)
  .LineStyle = xlContinuous
  .Weight = xlMedium
  .ColorIndex = xlAutomatic
  End With
  With Selection.Borders(xlEdgeBottom)
  .LineStyle = xlContinuous
  .Weight = xlMedium
  .ColorIndex = xlAutomatic
  End With
  With Selection.Borders(xlEdgeRight)
  .LineStyle = xlContinuous
  .Weight = xlMedium
  .ColorIndex = xlAutomatic
  End With
 
  ActiveSheet.PageSetup.PrintArea = I
  With ActiveSheet.PageSetup
  .Orientation = xlPortrait
  .Zoom = 75
'  .PrintErrors = xlPrintErrorsDisplayed
  .BlackAndWhite = False
  .Orientation = xlLandscape
  .Draft = False
  .PaperSize = xlPaperA4
  .FirstPageNumber = xlAutomatic
  .Order = xlDownThenOver
  .LeftMargin = Application.InchesToPoints(0.2)
  .RightMargin = Application.InchesToPoints(0.31)
  .TopMargin = Application.InchesToPoints(0.31)
  .BottomMargin = Application.InchesToPoints(0.45)
  .HeaderMargin = Application.InchesToPoints(0.22)
  .FooterMargin = Application.InchesToPoints(0.35)
  End With
 
 ActiveWindow.SelectedSheets.PrintPreview
 
End Sub


I am a Beginner....So, Please Can Someone Help Me in Implementing the Same Functionality using VB.Net

Regards,
Bala