If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
email pdf document
Hi,
Some time back, I entered a question asking if it was possible to be in Access, click on a command button, store a created pdf document in a "temp" file so that I might also be able to include, with code, the Access documents that I need to send with this file. I had to pull away from this project, but now am ready to tackle it again. Here is the code that was sent: Dim strFile(10) ‘assuming you have 11 or less files in the directory that you are wanting to attach. Dim tmp as string, i as integer, intFileCount as integer, strPath as string Dim strEmail as string, strCC as string, strBCC as string, strSubject as string, strMsg as string Sub EmailPDF() strPath = "C:\PathToPDF's\” tmp = Dir(strPath & “*.pdf”) While tmp "" strFile(i) = tmp i=i + 1 intFileCount = i tmp = Dir() Wend Dim outApp As Outlook.Application, outMsg As MailItem Set outApp = CreateObject("Outlook.Application") Set outMsg = outApp.CreateItem(olMailItem) strEmail = " strCC = " strBCC = " strSubject = "My PDF" strMsg = "Here's your PDF" With outMsg .Importance = olImportanceHigh .To = strEmail .CC = strCC .BCC = strBCC .Subject = strSubject .Body = strMsg For i = 1 to intFileCount -1 .Attachments.Add strPath & strFile(i) Next i .Display .Send End With Set outApp = Nothing Set outMsg = Nothing End Sub When I copied this code and replaced it with my file path, I received a message "Compile Error - Invalid or unqualified reference" and the .pdf is highlighted in the "tmp=" line of code. Hopefully, I've made what I'm trying to do clear and if anyone can help with this, it would be greatly appreciated. Thanks in advance, Pam |
#2
|
|||
|
|||
email pdf document
I don't see anything in that code that should be causing that problem.
Which "tmp=" line is it complaining about? The first one, where you pass it the path and wildcard. or the one inside the While loop? If the one inside the While loop, is it complaining the first time through the loop, or on a later iteration? What exactly did you change strPath to? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "PHisaw" wrote in message ... Hi, Some time back, I entered a question asking if it was possible to be in Access, click on a command button, store a created pdf document in a "temp" file so that I might also be able to include, with code, the Access documents that I need to send with this file. I had to pull away from this project, but now am ready to tackle it again. Here is the code that was sent: Dim strFile(10) 'assuming you have 11 or less files in the directory that you are wanting to attach. Dim tmp as string, i as integer, intFileCount as integer, strPath as string Dim strEmail as string, strCC as string, strBCC as string, strSubject as string, strMsg as string Sub EmailPDF() strPath = "C:\PathToPDF's\" tmp = Dir(strPath & "*.pdf") While tmp "" strFile(i) = tmp i=i + 1 intFileCount = i tmp = Dir() Wend Dim outApp As Outlook.Application, outMsg As MailItem Set outApp = CreateObject("Outlook.Application") Set outMsg = outApp.CreateItem(olMailItem) strEmail = " strCC = " strBCC = " strSubject = "My PDF" strMsg = "Here's your PDF" With outMsg .Importance = olImportanceHigh .To = strEmail .CC = strCC .BCC = strBCC .Subject = strSubject .Body = strMsg For i = 1 to intFileCount -1 .Attachments.Add strPath & strFile(i) Next i .Display .Send End With Set outApp = Nothing Set outMsg = Nothing End Sub When I copied this code and replaced it with my file path, I received a message "Compile Error - Invalid or unqualified reference" and the .pdf is highlighted in the "tmp=" line of code. Hopefully, I've made what I'm trying to do clear and if anyone can help with this, it would be greatly appreciated. Thanks in advance, Pam |
#3
|
|||
|
|||
email pdf document
Doug,
Thanks for the quick reply. Here is the line of code that the .pdf is highlighted in: tmp = Dir(strPath & “ * .pdf”) I changed the strPath to where the file was located on the server. Is this not right? The info I received with this was that I would have to change the path. Pam "Douglas J. Steele" wrote: I don't see anything in that code that should be causing that problem. Which "tmp=" line is it complaining about? The first one, where you pass it the path and wildcard. or the one inside the While loop? If the one inside the While loop, is it complaining the first time through the loop, or on a later iteration? What exactly did you change strPath to? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "PHisaw" wrote in message ... Hi, Some time back, I entered a question asking if it was possible to be in Access, click on a command button, store a created pdf document in a "temp" file so that I might also be able to include, with code, the Access documents that I need to send with this file. I had to pull away from this project, but now am ready to tackle it again. Here is the code that was sent: Dim strFile(10) 'assuming you have 11 or less files in the directory that you are wanting to attach. Dim tmp as string, i as integer, intFileCount as integer, strPath as string Dim strEmail as string, strCC as string, strBCC as string, strSubject as string, strMsg as string Sub EmailPDF() strPath = "C:\PathToPDF's\" tmp = Dir(strPath & "*.pdf") While tmp "" strFile(i) = tmp i=i + 1 intFileCount = i tmp = Dir() Wend Dim outApp As Outlook.Application, outMsg As MailItem Set outApp = CreateObject("Outlook.Application") Set outMsg = outApp.CreateItem(olMailItem) strEmail = " strCC = " strBCC = " strSubject = "My PDF" strMsg = "Here's your PDF" With outMsg .Importance = olImportanceHigh .To = strEmail .CC = strCC .BCC = strBCC .Subject = strSubject .Body = strMsg For i = 1 to intFileCount -1 .Attachments.Add strPath & strFile(i) Next i .Display .Send End With Set outApp = Nothing Set outMsg = Nothing End Sub When I copied this code and replaced it with my file path, I received a message "Compile Error - Invalid or unqualified reference" and the .pdf is highlighted in the "tmp=" line of code. Hopefully, I've made what I'm trying to do clear and if anyone can help with this, it would be greatly appreciated. Thanks in advance, Pam |
#4
|
|||
|
|||
email pdf document
It might make a difference what you specified, which is why I wanted the
exact value. I just tested using both UNC and mapped drive, and it worked fine for me. (I'm assuming you don't have the spaces around the asterisk) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "PHisaw" wrote in message ... Doug, Thanks for the quick reply. Here is the line of code that the .pdf is highlighted in: tmp = Dir(strPath & " * .pdf") I changed the strPath to where the file was located on the server. Is this not right? The info I received with this was that I would have to change the path. Pam "Douglas J. Steele" wrote: I don't see anything in that code that should be causing that problem. Which "tmp=" line is it complaining about? The first one, where you pass it the path and wildcard. or the one inside the While loop? If the one inside the While loop, is it complaining the first time through the loop, or on a later iteration? What exactly did you change strPath to? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "PHisaw" wrote in message ... Hi, Some time back, I entered a question asking if it was possible to be in Access, click on a command button, store a created pdf document in a "temp" file so that I might also be able to include, with code, the Access documents that I need to send with this file. I had to pull away from this project, but now am ready to tackle it again. Here is the code that was sent: Dim strFile(10) 'assuming you have 11 or less files in the directory that you are wanting to attach. Dim tmp as string, i as integer, intFileCount as integer, strPath as string Dim strEmail as string, strCC as string, strBCC as string, strSubject as string, strMsg as string Sub EmailPDF() strPath = "C:\PathToPDF's\" tmp = Dir(strPath & "*.pdf") While tmp "" strFile(i) = tmp i=i + 1 intFileCount = i tmp = Dir() Wend Dim outApp As Outlook.Application, outMsg As MailItem Set outApp = CreateObject("Outlook.Application") Set outMsg = outApp.CreateItem(olMailItem) strEmail = " strCC = " strBCC = " strSubject = "My PDF" strMsg = "Here's your PDF" With outMsg .Importance = olImportanceHigh .To = strEmail .CC = strCC .BCC = strBCC .Subject = strSubject .Body = strMsg For i = 1 to intFileCount -1 .Attachments.Add strPath & strFile(i) Next i .Display .Send End With Set outApp = Nothing Set outMsg = Nothing End Sub When I copied this code and replaced it with my file path, I received a message "Compile Error - Invalid or unqualified reference" and the is highlighted in the "tmp=" line of code. Hopefully, I've made what I'm trying to do clear and if anyone can help with this, it would be greatly appreciated. Thanks in advance, Pam |
#5
|
|||
|
|||
email pdf document
Sorry - here's the code as I have it now.
Private Sub Command235_Click() Dim strFile(10) Dim tmp As String, i As Integer, intFileCount As Integer, strPath As String Dim strEmail As String, strCC As String, strBCC As String, strSubject As String, strMsg As String strPath = "\\dell4lysk21\data\D T S\SCMP DECONTAMINATION GUIDELINES”" tmp = Dir(strPath & “ * .pdf”) While tmp "" strFile(i) = tmp i = i + 1 intFileCount = i tmp = Dir() Wend Dim outApp As Outlook.Application, outMsg As MailItem Set outApp = CreateObject("Outlook.Application") Set outMsg = outApp.CreateItem(olMailItem) strEmail = " strCC = " strBCC = " strSubject = "My PDF" strMsg = "Here's your PDF" With outMsg .Importance = olImportanceHigh .to = strEmail .CC = strCC .BCC = strBCC .Subject = strSubject .Body = strMsg For i = 1 To intFileCount - 1 .Attachments.Add strPath & strFile(i) Next i .Display .Send End With Set outApp = Nothing Set outMsg = Nothing End Sub "Douglas J. Steele" wrote: It might make a difference what you specified, which is why I wanted the exact value. I just tested using both UNC and mapped drive, and it worked fine for me. (I'm assuming you don't have the spaces around the asterisk) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "PHisaw" wrote in message ... Doug, Thanks for the quick reply. Here is the line of code that the .pdf is highlighted in: tmp = Dir(strPath & " * .pdf") I changed the strPath to where the file was located on the server. Is this not right? The info I received with this was that I would have to change the path. Pam "Douglas J. Steele" wrote: I don't see anything in that code that should be causing that problem. Which "tmp=" line is it complaining about? The first one, where you pass it the path and wildcard. or the one inside the While loop? If the one inside the While loop, is it complaining the first time through the loop, or on a later iteration? What exactly did you change strPath to? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "PHisaw" wrote in message ... Hi, Some time back, I entered a question asking if it was possible to be in Access, click on a command button, store a created pdf document in a "temp" file so that I might also be able to include, with code, the Access documents that I need to send with this file. I had to pull away from this project, but now am ready to tackle it again. Here is the code that was sent: Dim strFile(10) 'assuming you have 11 or less files in the directory that you are wanting to attach. Dim tmp as string, i as integer, intFileCount as integer, strPath as string Dim strEmail as string, strCC as string, strBCC as string, strSubject as string, strMsg as string Sub EmailPDF() strPath = "C:\PathToPDF's\" tmp = Dir(strPath & "*.pdf") While tmp "" strFile(i) = tmp i=i + 1 intFileCount = i tmp = Dir() Wend Dim outApp As Outlook.Application, outMsg As MailItem Set outApp = CreateObject("Outlook.Application") Set outMsg = outApp.CreateItem(olMailItem) strEmail = " strCC = " strBCC = " strSubject = "My PDF" strMsg = "Here's your PDF" With outMsg .Importance = olImportanceHigh .To = strEmail .CC = strCC .BCC = strBCC .Subject = strSubject .Body = strMsg For i = 1 to intFileCount -1 .Attachments.Add strPath & strFile(i) Next i .Display .Send End With Set outApp = Nothing Set outMsg = Nothing End Sub When I copied this code and replaced it with my file path, I received a message "Compile Error - Invalid or unqualified reference" and the is highlighted in the "tmp=" line of code. Hopefully, I've made what I'm trying to do clear and if anyone can help with this, it would be greatly appreciated. Thanks in advance, Pam |
#6
|
|||
|
|||
email pdf document
You appear to have a "smart quote" (") rather than a slash at the end of
strPath. I also think you need to remove at least the blank before the * in tmp = Dir(strPath & " * .pdf") (I don't think it's possible for a file name to start with a space, which is what that would retrieve) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "PHisaw" wrote in message ... Sorry - here's the code as I have it now. Private Sub Command235_Click() Dim strFile(10) Dim tmp As String, i As Integer, intFileCount As Integer, strPath As String Dim strEmail As String, strCC As String, strBCC As String, strSubject As String, strMsg As String strPath = "\\dell4lysk21\data\D T S\SCMP DECONTAMINATION GUIDELINES"" tmp = Dir(strPath & " * .pdf") While tmp "" strFile(i) = tmp i = i + 1 intFileCount = i tmp = Dir() Wend Dim outApp As Outlook.Application, outMsg As MailItem Set outApp = CreateObject("Outlook.Application") Set outMsg = outApp.CreateItem(olMailItem) strEmail = " strCC = " strBCC = " strSubject = "My PDF" strMsg = "Here's your PDF" With outMsg .Importance = olImportanceHigh .to = strEmail .CC = strCC .BCC = strBCC .Subject = strSubject .Body = strMsg For i = 1 To intFileCount - 1 .Attachments.Add strPath & strFile(i) Next i .Display .Send End With Set outApp = Nothing Set outMsg = Nothing End Sub "Douglas J. Steele" wrote: It might make a difference what you specified, which is why I wanted the exact value. I just tested using both UNC and mapped drive, and it worked fine for me. (I'm assuming you don't have the spaces around the asterisk) -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "PHisaw" wrote in message ... Doug, Thanks for the quick reply. Here is the line of code that the .pdf is highlighted in: tmp = Dir(strPath & " * .pdf") I changed the strPath to where the file was located on the server. Is this not right? The info I received with this was that I would have to change the path. Pam "Douglas J. Steele" wrote: I don't see anything in that code that should be causing that problem. Which "tmp=" line is it complaining about? The first one, where you pass it the path and wildcard. or the one inside the While loop? If the one inside the While loop, is it complaining the first time through the loop, or on a later iteration? What exactly did you change strPath to? -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "PHisaw" wrote in message ... Hi, Some time back, I entered a question asking if it was possible to be in Access, click on a command button, store a created pdf document in a "temp" file so that I might also be able to include, with code, the Access documents that I need to send with this file. I had to pull away from this project, but now am ready to tackle it again. Here is the code that was sent: Dim strFile(10) 'assuming you have 11 or less files in the directory that you are wanting to attach. Dim tmp as string, i as integer, intFileCount as integer, strPath as string Dim strEmail as string, strCC as string, strBCC as string, strSubject as string, strMsg as string Sub EmailPDF() strPath = "C:\PathToPDF's\" tmp = Dir(strPath & "*.pdf") While tmp "" strFile(i) = tmp i=i + 1 intFileCount = i tmp = Dir() Wend Dim outApp As Outlook.Application, outMsg As MailItem Set outApp = CreateObject("Outlook.Application") Set outMsg = outApp.CreateItem(olMailItem) strEmail = " strCC = " strBCC = " strSubject = "My PDF" strMsg = "Here's your PDF" With outMsg .Importance = olImportanceHigh .To = strEmail .CC = strCC .BCC = strBCC .Subject = strSubject .Body = strMsg For i = 1 to intFileCount -1 .Attachments.Add strPath & strFile(i) Next i .Display .Send End With Set outApp = Nothing Set outMsg = Nothing End Sub When I copied this code and replaced it with my file path, I received a message "Compile Error - Invalid or unqualified reference" and the is highlighted in the "tmp=" line of code. Hopefully, I've made what I'm trying to do clear and if anyone can help with this, it would be greatly appreciated. Thanks in advance, Pam |
#7
|
|||
|
|||
email pdf document
Pam,
As well as removing the spaces, you might also need to retype this line, as it appears to be enclosed in rather than "" (which probably indicates it was originally copy/pasted from a word processor or newsreader which munged it). -- Steve Schapel, Microsoft Access MVP Douglas J. Steele wrote: You appear to have a "smart quote" (") rather than a slash at the end of strPath. I also think you need to remove at least the blank before the * in tmp = Dir(strPath & " * .pdf") (I don't think it's possible for a file name to start with a space, which is what that would retrieve) |
#8
|
|||
|
|||
email pdf document
Doug/Steve,
Thanks again for the help. I've got past this line of code, but it's stopping at the last line of text shown below. I've only entered the first part up to where it's causing an error. I also wanted you to verify the changes were correct I made. On the last line, I get message "User-defined type not defined". Thanks, Pam "Steve Schapel" wrote: Pam, As well as removing the spaces, you might also need to retype this line, as it appears to be enclosed in “” rather than "" (which probably indicates it was originally copy/pasted from a word processor or newsreader which munged it). -- Steve Schapel, Microsoft Access MVP Douglas J. Steele wrote: You appear to have a "smart quote" (") rather than a slash at the end of strPath. I also think you need to remove at least the blank before the * in tmp = Dir(strPath & " * .pdf") (I don't think it's possible for a file name to start with a space, which is what that would retrieve) |
#9
|
|||
|
|||
email pdf document
Sorry I forgot to paste the code in
strPath = "\\dell4lysk21\data\D T S\SCMP DECONTAMINATION GUIDELINES\" tmp = Dir(strPath & "* .pdf") While tmp "" strFile(i) = tmp i = i + 1 intFileCount = i tmp = Dir() Wend Dim outApp As Outlook.Application, outMsg As MailItem "Steve Schapel" wrote: Pam, As well as removing the spaces, you might also need to retype this line, as it appears to be enclosed in “” rather than "" (which probably indicates it was originally copy/pasted from a word processor or newsreader which munged it). -- Steve Schapel, Microsoft Access MVP Douglas J. Steele wrote: You appear to have a "smart quote" (") rather than a slash at the end of strPath. I also think you need to remove at least the blank before the * in tmp = Dir(strPath & " * .pdf") (I don't think it's possible for a file name to start with a space, which is what that would retrieve) |
#10
|
|||
|
|||
email pdf document
Have you set a reference to Outlook (through Tools | References)?
-- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no private e-mails, please) "PHisaw" wrote in message ... Sorry I forgot to paste the code in strPath = "\\dell4lysk21\data\D T S\SCMP DECONTAMINATION GUIDELINES\" tmp = Dir(strPath & "* .pdf") While tmp "" strFile(i) = tmp i = i + 1 intFileCount = i tmp = Dir() Wend Dim outApp As Outlook.Application, outMsg As MailItem "Steve Schapel" wrote: Pam, As well as removing the spaces, you might also need to retype this line, as it appears to be enclosed in "" rather than "" (which probably indicates it was originally copy/pasted from a word processor or newsreader which munged it). -- Steve Schapel, Microsoft Access MVP Douglas J. Steele wrote: You appear to have a "smart quote" (") rather than a slash at the end of strPath. I also think you need to remove at least the blank before the * in tmp = Dir(strPath & " * .pdf") (I don't think it's possible for a file name to start with a space, which is what that would retrieve) |
|
Thread Tools | |
Display Modes | |
|
|