Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-05-2017, 05:45 AM
tas75 tas75 is offline automatic reply with parametric Excel file attached Windows 7 32bit automatic reply with parametric Excel file attached Office 2007
Novice
automatic reply with parametric Excel file attached
 
Join Date: Mar 2017
Posts: 4
tas75 is on a distinguished road
Default automatic reply with parametric Excel file attached


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???
Reply With Quote
  #2  
Old 12-05-2017, 07:13 AM
gmayor's Avatar
gmayor gmayor is offline automatic reply with parametric Excel file attached Windows 10 automatic reply with parametric Excel file attached Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
Reply With Quote
  #3  
Old 12-06-2017, 12:34 AM
tas75 tas75 is offline automatic reply with parametric Excel file attached Windows 7 32bit automatic reply with parametric Excel file attached Office 2007
Novice
automatic reply with parametric Excel file attached
 
Join Date: Mar 2017
Posts: 4
tas75 is on a distinguished road
Smile

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...
Reply With Quote
  #4  
Old 12-06-2017, 05:38 AM
gmayor's Avatar
gmayor gmayor is offline automatic reply with parametric Excel file attached Windows 10 automatic reply with parametric Excel file attached Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

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
In Outlook, you need a rule to identify the messages that require the reply and then run the script xlGetData to process those messages as they arrive e.g. as follows.

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
You can run the following macro with a selected message to test the process
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.
Reply With Quote
  #5  
Old 12-06-2017, 06:13 AM
tas75 tas75 is offline automatic reply with parametric Excel file attached Windows 7 32bit automatic reply with parametric Excel file attached Office 2007
Novice
automatic reply with parametric Excel file attached
 
Join Date: Mar 2017
Posts: 4
tas75 is on a distinguished road
Default

i will try to synthesize it and i will get back to you! thank you for the tremendous help!
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
automatic reply with parametric Excel file attached Automatic SMS from Excel file with condition 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
automatic reply with parametric Excel file attached Automatic update of links in template - closing attached template without saving stefaan Word 2 11-02-2013 07:46 AM
Automatic reply with variable attachment subby80 Outlook 0 10-20-2011 06:59 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:38 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft