Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have a procedure detailed below which was created, thanks to support from
this group, to remove highlighted areas from worksheets before printing an area and then after printing to return the sheet to the areas highlighted as before. This works fine but there is a problem which can occur in two situations. If the procedure is activated (from a button ) when a printer is not connected or if a printer error occurs during printing (which does happen on some network printers), then the sheet is left with the areas without the highlights. ie the line to restore the highlights is after the print command as you will see. Is there a way to error trap for this type of situation? I as always value any help or guidance. Sub printmargins() Dim myRng As Range Dim myColorIndex As Long Dim sh As Worksheet For Each sh In ThisWorkbook.Worksheets If sh.Range("C2").Value 0 Then Set myRng = Nothing On Error Resume Next Set myRng = sh.Range(sh.Name) On Error GoTo 0 If myRng Is Nothing Then 'do nothing, it didn't have a range with the worksheet name Else myColorIndex = myRng(1).Interior.ColorIndex myRng.Interior.ColorIndex = xlNone With sh.PageSetup .Orientation = xlPortrait .FitToPagesWide = 1 .FitToPagesTall = 1 .LeftMargin = Application.InchesToPoints(0.551181102362205) .RightMargin = Application.InchesToPoints(0.15748031496063) End With sh.Range("PRGM").PrintOut myRng.Interior.ColorIndex = myColorIndex End If End If Next sh End Sub Kind regards, Graham Haughs Turriff, Scotland |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
members on my network printer not able to print to default printer | Excel Discussion (Misc queries) | |||
Printer Multiple Worksheets with a particular Printer Setting | Excel Worksheet Functions | |||
Change event fails to work | Excel Worksheet Functions | |||
change event/after update event?? | Excel Programming | |||
OnTime event not firing in Workbook_Open event procedure | Excel Programming |