none
Resize a table keeping the old data ... RRS feed

  • Question

  • Hi,

    I use this code (that works perfectly) to select files to attach to an email before launching a mailing, from Word to Outlook...

    Option Explicit
    Public Const strBox = "Cnam Languedoc-Roussillon 2011-"
    Public strFile As Variant
    Public fileList() As String
    Sub ePubPJ()
        Dim xlApp As New Excel.Application          'requires Microsoft Excel ##.0 Object Library
        Dim i As Integer                           
        strFile = xlApp.GetOpenFilename(, , strBox & VBA.Year(Date), , True)
        If IsArray(strFile) Then
            i = UBound(strFile)
            ReDim fileList(i)
            For i = LBound(strFile) To UBound(strFile)
                fileList(i) = strFile(i)
            Next i
        End If

    End Sub

    Now I will wish to leave open the possibility for the user to add, if desired, other files. I thought of doing so ...

    Option Explicit
    Public Const strBox = "Cnam Languedoc-Roussillon 2011-"
    Public strFile As Variant
    Public fileList() As String
    Sub ePubPJ()
        Dim xlApp As New Excel.Application          'requires Microsoft Excel ##.0 Object Library
        Dim i As Integer                            
        Dim n As Integer
        Dim othFile As Integer
        Do
            strFile = xlApp.GetOpenFilename(, , strBox & VBA.Year(Date), , True)
            If IsArray(strFile) Then
                n = n + UBound(strFile)
                ReDim Preserve fileList(n)
                For i = LBound(strFile) To UBound(strFile)
                    fileList(n) = strFile(i)
                Next i
                othFile = MsgBox("Other files to join ?", 4 + 64, strBox & VBA.Year(Date))
                If othFile <> vbYes Then Exit Do
            Else
                Exit Do
            End If
        Loop

    End Sub

    but it does not work ! :(
    Would anyone track?

    Thank you in advance for any answers that you will make.
    ChrisV
    Friday, July 12, 2013 5:38 PM

Answers

  • What exactly are you trying to do in Outlook?  If you want to attach files to a message, use the MailItem.Attachments.Add method.

    Attachments.Add Method (Outlook)
    http://msdn.microsoft.com/en-us/library/ff869553.aspx


    Eric Legault (MVP: Outlook)
    About me...
    Outlook Appins: Store Social Media fields in your Outlook Contacts!

    Monday, July 15, 2013 3:36 PM
    Moderator