Skip to content

Instantly share code, notes, and snippets.

@shebpamm
Last active November 14, 2020 17:23
Show Gist options
  • Save shebpamm/f466576acbd44903af9e25d78e473147 to your computer and use it in GitHub Desktop.
Save shebpamm/f466576acbd44903af9e25d78e473147 to your computer and use it in GitHub Desktop.
Tippimakro
Sub pdfTest()
Dim sFile As Variant
Dim strPath As String
Dim strPathFile As String
Dim strSaveBasePath As String
Dim strCurrentMonth As String
Dim targetTime As Variant
targetTime = Now()
'targetTime = CDate("2021-01-01 03:00:00")
If Hour(targetTime) <= 5 Then
targetTime = DateAdd("d", -1, targetTime)
End If
Debug.Print targetTime
strSaveBasePath = "\\office\tiedostot\Veikkaus_tyoryhmat\Pelisalien kirjanpito\Feel Vegas Helsinki Tripla\Tipit"
strCurrentMonth = WorksheetFunction.Proper(WorksheetFunction.Text(targetTime, "[$-040B]mmmm"))
strPath = strSaveBasePath & "\" & strCurrentMonth & " " & Format(targetTime, "yyyy")
strPathFile = strPath & "\" & Format(targetTime, "yyyy mm dd") & " Tipit"
sFile = Application.GetSaveAsFilename _
(InitialFileName:=strPathFile, _
FileFilter:="PDF Files (*.pdf), *.pdf", _
Title:="Tarkista sijainti")
If sFile <> "False" Then
ActiveWorkbook.ExportAsFixedFormat _
Type:=xlTypePDF, _
Filename:=sFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=True, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=True
End If
End Sub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment