![]() |
#1
|
|||
|
|||
![]() i have an excel file in "c:/desktop/files" where, by inputting a unique customer code, an one-page report is produced with all customer's data. What i need, is: 1. my colleagues to be able to send an empty e-mail, via outlook 2007, with only the customer code in the subject line 2. the excel file to run (either firstly the excel file to be automatically opened or, if not possible, i should have it always running) for this customer code 3. a pdf to be produced and saved in "c:/desktop/pdf files" 4. an automatic reply to be sent to the colleague with the pdf attached. I know this can be done as i have seen it happening in other organisations but i do not know how to do it... any ideas for that??? |
#2
|
||||
|
||||
![]()
Automatic? What constitutes 'automatic' in this context?
With regard to '1'. Do I take it that the Outlook message with just a subject is sent to you and that as a consequence, you create the reply with the attachment and send it back? That should be feasible but it seems to be a tortuous process. You would need a rule to identify the incoming messages that fit the bill and run a script that opens Excel, creates and saves the PDF and attaches it to a reply. You will need to modify your existing Excel macro so that it can be called with the customer code parameter. Why not simply give the colleagues access to Excel file, let them create the pdfs and forget all about the e-mails?
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
Well, "automatic" refers to an automated routine that constitutes of a series of complicated steps
![]() I don't want to give access to the full file because the file (~200 MB) contains the entire exhaustive info and data for the entire portfolio of ~300k customers - it wouldn't be a good idea that everyone can take this valuable data and handle it in ambiguous ways... We agree on the process - however i would really need help for the part that has to do with the explicit code needed... |
#4
|
||||
|
||||
![]()
Without access to the workbook, I can only point you in the right direction. The process itself is simple enough. You will need a function in your workbook that takes the ID from the e-mail, creates the PDF and returns the PDF path and name. The basics are
Code:
Function MacroName(strID As String) As String 'Run your workbook code here MacroName = "C:\path\" & strID & ".pdf" ' return the PDF path and name End Function Change the various parts to reflect the true names of your workbook and the function. If you are comfortable with VBA, you should be able to make this work with your workbook. It tests OK with the examples used. Code:
Option Explicit Public Sub xlGetData(olItem As MailItem) Const strWorkBook As String = "C:\Path\Workbookname.xlsm" 'The name of the workbook Dim xlApp As Object Dim xlWB As Object Dim strID As String Dim strPDF As String Dim bStarted As Boolean Dim olReply As MailItem Dim fso As Object strID = olItem.Subject On Error Resume Next Set xlApp = GetObject(, "Excel.Application") If Err <> 0 Then Set xlApp = CreateObject("Excel.Application") bStarted = True End If On Error GoTo 0 Set xlWB = xlApp.workbooks.Open(strWorkBook) strPDF = xlApp.Run("'" & xlWB.Name & "'!MacroName", strID) Set fso = CreateObject("Scripting.FileSystemObject") If fso.FileExists(strPDF) Then Set olReply = olItem.Reply With olReply .Attachments.Add strPDF .Display '.Send 'Restore this line after testing End With Debug.Print strID & vbTab & strPDF Else MsgBox "The file" & vbCr & strPDF & vbCr & "does not exist." End With lbl_Exit: xlWB.Close 0 If bStarted Then xlApp.Quit End If Set xlApp = Nothing Set xlWB = Nothing Exit Sub End Sub Code:
Sub TestMacro() Dim olMsg As MailItem On Error Resume Next Set olMsg = ActiveExplorer.Selection.Item(1) xlGetData olMsg lbl_Exit: Exit Sub End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com Last edited by gmayor; 12-07-2017 at 01:49 AM. |
#5
|
|||
|
|||
![]()
i will try to synthesize it and i will get back to you! thank you for the tremendous help!
|
![]() |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
aspirout | Excel Programming | 3 | 11-02-2019 04:17 AM |
auto respond with parametric attachment upon request | tas75 | Outlook | 0 | 03-05-2017 11:14 AM |
copy data from outlook attached excel file into a local one | s_samira_21 | Outlook | 4 | 09-17-2014 11:46 PM |
![]() |
stefaan | Word | 2 | 11-02-2013 07:46 AM |
Automatic reply with variable attachment | subby80 | Outlook | 0 | 10-20-2011 06:59 AM |