내역관련/내역자료

노란색을 무색으로 변경, PDF 출판 후 원상복구

고추탄 2026. 1. 22. 13:51

※ Copilot 질의 응답

Sub PrintWithoutYellowFast()
    
    Dim rng As Range
    Dim arr_org() As Long
    Dim i As Long
    
    Set rng = ActiveSheet.UsedRange
    
   '원래 색상 저장
    ReDim arr_org(1 To rng.Cells.Count)
    
    For i = 1 To rng.Cells.Count
        arr_org(i) = rng.Cells(i).Interior.Color
        If rng.Cells(i).Interior.Color = RGB(255, 255, 0) Then
            rng.Cells(i).Interior.Color = RGB(255, 255, 255) ' 노란색만 흰색으로 변경
        End If
    Next i
    
   '인쇄
   'ActiveSheet.PrintOut
   
   'PDF인쇄
    Call SaveActiveSheetAsPDF
   
    
   '원상복구
    For i = 1 To rng.Cells.Count
        rng.Cells(i).Interior.Color = arr_org(i)
    Next i
    
End Sub


Sub SaveActiveSheetAsPDF()
    
    Dim ws As Worksheet
    Dim pdfPath As String
    
   '현재 활성 시트
    Set ws = ActiveSheet
    
   '저장 경로 (예: 현재 워크북과 같은 폴더)
    pdfPath = ThisWorkbook.Path & "\" & _
              ThisWorkbook.Name & "_" & ws.Name & ".pdf"
    
   'PDF로 내보내기
    ws.ExportAsFixedFormat Type:=xlTypePDF, _
                           Filename:=pdfPath, _
                           Quality:=xlQualityStandard, _
                           IncludeDocProperties:=True, _
                           IgnorePrintAreas:=False, _
                           OpenAfterPublish:=False

End Sub

노란색을 무색으로 변경, PDF 출판 후 복구.txt
0.00MB

LIST