jakub1241996
New Member
- Joined
- Jan 21, 2023
- Messages
- 2
- Office Version
- 365
- Platform
- Windows
Hello please help not working PDF
Sub PDF_SAVE()
Application.ScreenUpdating = False
Dim PatientName As String, Dt As String
myFolderName = Environ("userprofile") & "\SPMO\Reklamace - Reklamace\"
Dim strFileName As String
Dim objOutlook As Object
Dim objMailItem As Object
With ActiveDocument
strFileName = Replace(ActiveDocument.FullName, ".docm", ".pdf")
Dl = " " & Trim(Split(Split(.Range.Text, "Dodací list:")(1), vbCr)(0))
Shipment = " " & Trim(Split(Split(.Range.Text, "Shipment (ASTRO WMS):")(1), vbCr)(0))
RP = "__RP"
ActiveDocument.SaveAs2 myFolderName & RP & Dl & Shipment & ".pdf", FileFormat:=wdFormatText, AddToRecentFiles:=False
ActiveDocument.ExportAsFixedFormat OutputFileName:=strFileName, _
ExportFormat:=wdExportFormatPDF
Set objOutlook = CreateObject("Outlook.Application")
Set objMailItem = objOutlook.CreateItem(0) ' 0 = olMailItem
With objMailItem
.Subject = "& RP & Dl &"
.Body = "My Message"
.To = "jakub@sp.cz"
.Attachments.Add strFileName
.Display
End With
Kill strFileName
Set objMailItem = Nothing
Set objOutlook = Nothing
End With
Dim bExists As Boolean
Dim MyPrint As Dialog
' ensure our doc variable exists
bExists = False
For Each varItem In ActiveDocument.CustomDocumentProperties
If varItem.Name = "Copies" Then
bExists = True
Exit For
End If
Next varItem
' initialize document variable if doesn't exist
If Not bExists Then
ActiveDocument.CustomDocumentProperties.Add _
Name:="Copies", LinkToContent:=False, _
Type:=msoPropertyTypeNumber, Value:=1
End If
Set MyPrint = Dialogs(wdDialogFilePrint)
With MyPrint
.NumCopies = ActiveDocument.CustomDocumentProperties("Copies")
.Show
End With
ActiveDocument.CustomDocumentProperties("Copies") = _
MyPrint.NumCopies
Dim windowsObject As Object
Application.ScreenUpdating = False
End Sub
Sub PDF_SAVE()
Application.ScreenUpdating = False
Dim PatientName As String, Dt As String
myFolderName = Environ("userprofile") & "\SPMO\Reklamace - Reklamace\"
Dim strFileName As String
Dim objOutlook As Object
Dim objMailItem As Object
With ActiveDocument
strFileName = Replace(ActiveDocument.FullName, ".docm", ".pdf")
Dl = " " & Trim(Split(Split(.Range.Text, "Dodací list:")(1), vbCr)(0))
Shipment = " " & Trim(Split(Split(.Range.Text, "Shipment (ASTRO WMS):")(1), vbCr)(0))
RP = "__RP"
ActiveDocument.SaveAs2 myFolderName & RP & Dl & Shipment & ".pdf", FileFormat:=wdFormatText, AddToRecentFiles:=False
ActiveDocument.ExportAsFixedFormat OutputFileName:=strFileName, _
ExportFormat:=wdExportFormatPDF
Set objOutlook = CreateObject("Outlook.Application")
Set objMailItem = objOutlook.CreateItem(0) ' 0 = olMailItem
With objMailItem
.Subject = "& RP & Dl &"
.Body = "My Message"
.To = "jakub@sp.cz"
.Attachments.Add strFileName
.Display
End With
Kill strFileName
Set objMailItem = Nothing
Set objOutlook = Nothing
End With
Dim bExists As Boolean
Dim MyPrint As Dialog
' ensure our doc variable exists
bExists = False
For Each varItem In ActiveDocument.CustomDocumentProperties
If varItem.Name = "Copies" Then
bExists = True
Exit For
End If
Next varItem
' initialize document variable if doesn't exist
If Not bExists Then
ActiveDocument.CustomDocumentProperties.Add _
Name:="Copies", LinkToContent:=False, _
Type:=msoPropertyTypeNumber, Value:=1
End If
Set MyPrint = Dialogs(wdDialogFilePrint)
With MyPrint
.NumCopies = ActiveDocument.CustomDocumentProperties("Copies")
.Show
End With
ActiveDocument.CustomDocumentProperties("Copies") = _
MyPrint.NumCopies
Dim windowsObject As Object
Application.ScreenUpdating = False
End Sub