Created
June 26, 2018 22:36
-
-
Save hedgejanuary/2838074f754c80b57e8920319e9c3628 to your computer and use it in GitHub Desktop.
Exporting a worksheet data to PDF.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Option Explicit | |
Sub NotificationLetter_ExportToPDF() | |
Dim Team As String '所属チーム名 | |
Const FirstRow As 4 'データシートの一番初めのデータ | |
Dim FinalRow As Long 'データベース最終行 | |
Dim i As Long 'カウンタ変数 | |
'データシートの名前を変数に格納 | |
Dim dSheet As String | |
dSheet = "Database" | |
'通知書シートの名前を変数に格納 | |
Dim lSheet As String | |
lSheet = "Letter" | |
FinalRow = Worksheets(dSheet).Cells(Rows.Count, 1).End(xlUp).Row | |
Team = Worksheets(lSheet).Cells(17,4).Value | |
For i = FirstRow to FinalRow | |
'変数Teamに格納された値とデータシートE列の値が同じ場合、作業を進める。 | |
If Worksheets(dSheet).Cells(i, "E").Value = Team then | |
With Worksheets(lSheet) | |
.Cells(3, 2).value = Worksheets(dSheet).Cells(i, 1).value | |
ActiveSheet.ExportAsFixedFormat _ | |
Type:=xlTypePDF, _ | |
Filename:=ThisWorkbook.Path & "¥" & Year(Now()) & "_Notification_" & Team _ | |
& "_" & Worksheets(dSheet).Cells(i, "C").Value & ".pdf", _ | |
Quality:=xlQualityStandard, _ | |
Includedocproperties:=True, _ | |
Ignoreprintareas:=False, _ | |
openafterpublish:=False | |
End With | |
End IF | |
Next i | |
MsgBox "通知書が【" & ThisWorkbook.Path & "】フォルダ内に格納されました。" | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment