colinharwood
Active Member
- Joined
- Jul 27, 2002
- Messages
- 440
- Office Version
- 365
- Platform
- Windows
Hi
When using the following code, I get a runtime error 76, path not found, when the mkdir line is reached can anyone please explain what is wrong.
Thanks
Sub PrintPDFCard()
Dim ThisFile As String
Dim FileDrive As String
Dim strFolderName As String
Dim strFolderExists As String
'Check if folder exists
strFolderName = "C:\users\adria\tonbridge mes folders\TMES email renewals"
strFolderExists = Dir(strFolderName, vbDirectory)
If strFolderExists = "" Then
'If folder doesn't exist"
MkDir "C:\users\adria\tonbridge mes folders\TMES email renewals\"
Else
'If folder does exist
GoTo CreatePDF
End If
CreatePDF:
CreateObject("WScript.Network").SetDefaultPrinter "Microsoft Print to PDF"
Range("$A$1:$H$42").Select
ThisFile = Range("N3").Value & " " & Range("O3").Value
FileDrive = "C:\TMES email renewals\"
Selection.PrintOut Copies:=1, ActivePrinter:= _
"Microsoft print to pdf", Collate:=True, _
printtofile:=True, prtofilename:=FileDrive & ThisFile & ".pdf"
Sheets("PDF Membership Card").Range("S1").Select
CreateEmail:
' Create Email to someone
sCmd = "C:\Program Files\Mozilla Thunderbird\thunderbird.exe"
Email = Range("N4").Value 'email address
Subject = "PDF Membership Card"
Content = "Hi%20%0A%0APlease find attached a PDF Membership Card%20%0A%0ARegards%0A%0AAdrian Banks%0A%0ATreasurer"
Attch = "C:\TMES email renewals\" & ThisFile & ".pdf" ' file name and path
sCmd = sCmd & " -compose " & "to=" & Email
sCmd = sCmd & ",subject=" & Subject
sCmd = sCmd & ",attachment=" & Attch
sCmd = sCmd & ",body=" & Content
Call Shell(sCmd, vbNormalFocus)
End Sub
When using the following code, I get a runtime error 76, path not found, when the mkdir line is reached can anyone please explain what is wrong.
Thanks
Sub PrintPDFCard()
Dim ThisFile As String
Dim FileDrive As String
Dim strFolderName As String
Dim strFolderExists As String
'Check if folder exists
strFolderName = "C:\users\adria\tonbridge mes folders\TMES email renewals"
strFolderExists = Dir(strFolderName, vbDirectory)
If strFolderExists = "" Then
'If folder doesn't exist"
MkDir "C:\users\adria\tonbridge mes folders\TMES email renewals\"
Else
'If folder does exist
GoTo CreatePDF
End If
CreatePDF:
CreateObject("WScript.Network").SetDefaultPrinter "Microsoft Print to PDF"
Range("$A$1:$H$42").Select
ThisFile = Range("N3").Value & " " & Range("O3").Value
FileDrive = "C:\TMES email renewals\"
Selection.PrintOut Copies:=1, ActivePrinter:= _
"Microsoft print to pdf", Collate:=True, _
printtofile:=True, prtofilename:=FileDrive & ThisFile & ".pdf"
Sheets("PDF Membership Card").Range("S1").Select
CreateEmail:
' Create Email to someone
sCmd = "C:\Program Files\Mozilla Thunderbird\thunderbird.exe"
Email = Range("N4").Value 'email address
Subject = "PDF Membership Card"
Content = "Hi%20%0A%0APlease find attached a PDF Membership Card%20%0A%0ARegards%0A%0AAdrian Banks%0A%0ATreasurer"
Attch = "C:\TMES email renewals\" & ThisFile & ".pdf" ' file name and path
sCmd = sCmd & " -compose " & "to=" & Email
sCmd = sCmd & ",subject=" & Subject
sCmd = sCmd & ",attachment=" & Attch
sCmd = sCmd & ",body=" & Content
Call Shell(sCmd, vbNormalFocus)
End Sub