Results 1 to 14 of 14
  1. #1
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496

    Browse computer for attachment, email attachment.


    I have

    button attach file to email on a form

    on click it should open file open dialog box and help the user locate the word or pdf file on their computer

    then they click attach

    there is a unbound text box on the form which I hope to display the filepath (to indicate an attachment is attached)

    then do a docmd.sendobject and have that file as the attachment. (me.txtFilePath)

    I've been looking around on the web for a guide but with no luck... so I have to ask.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Check this out. I can't remember exactly what the thread was about but I think it may at least get you started. I posted a sample DB on this here
    https://www.accessforums.net/program...57/index2.html

  3. #3
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by ItsMe View Post
    Check this out. I can't remember exactly what the thread was about but I think it may at least get you started. I posted a sample DB on this here
    https://www.accessforums.net/program...57/index2.html
    Love the santa hat

  4. #4
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by ItsMe View Post
    Check this out. I can't remember exactly what the thread was about but I think it may at least get you started. I posted a sample DB on this here
    https://www.accessforums.net/program...57/index2.html
    I've had a read through - from what I see the onclick allows you to bring up the dialog using "application." however that is where I get the error. I don't need to save the information into any table field so I'm not sure if I have to deal with DAO?

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    No, the DAO function is for the other thing. But the file picker should work for you. Doesn't it save the path in a string? You could use that with your Email object.

  6. #6
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    I pasted (everything from the cmdPicker onclick event on your form) on the button onclick.

    It comes up with this error

    Click image for larger version. 

Name:	Capture.JPG 
Views:	11 
Size:	23.3 KB 
ID:	14650

    Am I missing something here?

  7. #7
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by Ruegen View Post
    I pasted (everything from the cmdPicker onclick event on your form) on the button onclick.

    It comes up with this error

    Click image for larger version. 

Name:	Capture.JPG 
Views:	11 
Size:	23.3 KB 
ID:	14650

    Am I missing something here?
    I thought since I only need to save the path and take no other action

    Your code copied

    I added the dim

    Code:
    Dim strPath As String
    
    
    ' User asked to add a new photo
    'Dim strPath As String
    ' Grab a copy of the Office file dialog
    With Application.FileDialog(msoFileDialogFilePicker)
    ' Select only one file
    .AllowMultiSelect = False
    ' Set the dialog title
    .Title = "Locate a file to attach"
    ' Set the button caption
    .ButtonName = "Choose"
    ' Make sure the filter list is clear
    
    
    
    
    .Filters.Clear
    ' Add two filters
    '.Filters.Add "JPEGs", "*.jpg"
    .Filters.Add "All Files", "*.*"
    
    
    
    
    ' Set the filter index to 2
    '.FilterIndex = 2
    ' Set the initial path name
    '.InitialFileName = CurrentProject.Path & "\Pictures"
    
    
    .InitialFileName = "C:\"
    
    
    ' Show files as thumbnails
    .InitialView = msoFileDialogViewThumbnail
    ' Show the dialog and test the return
    If .SHOW = 0 Then
    ' Didn't pick a file - bail
    Exit Sub
    End If
    ' Should be only one filename - grab it
    strPath = Trim(.SelectedItems(1))
    
    
    ' Set an error trap
    On Error Resume Next
    ' Set the image
    'Me.txtPhoto = strPath
    ' Set the message in case Image control couldn't find it
    'Me.lblMsg.Caption = "Failed to load the file you selected." & _
    '" Click Picker to try again."
    End With
    ' Put focus in a safe place
    Me.SetFocus

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Reference
    Microsoft Office XX.X Object Library

    Not to be confused with Access Object Library

  9. #9
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by ItsMe View Post
    Reference
    Microsoft Office XX.X Object Library

    Not to be confused with Access Object Library
    so XX.X is the version?

    Since I have Office 2010....?


    14.0 ?

    dim refname as reference

    refname =
    C:\Program Files\Microsoft Office\Office14\msacc.olb

    I know nothing about reference...

    Click image for larger version. 

Name:	Capture.JPG 
Views:	11 
Size:	52.9 KB 
ID:	14652

  10. #10
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    In the VBA editor got to Tools>References and then tick

    Microsoft Office 14.0 Object Library

    from your available references list. Click OK. This is your library for early binding.

    some more info
    http://allenbrowne.com/ser-38.html

  11. #11
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by Ruegen View Post
    so XX.X is the version?

    Since I have Office 2010....?


    14.0 ?

    dim refname as reference

    refname =
    C:\Program Files\Microsoft Office\Office14\msacc.olb

    I know nothing about reference...

    Click image for larger version. 

Name:	Capture.JPG 
Views:	11 
Size:	52.9 KB 
ID:	14652

    found it - works thanks sorry

    long learning curve of mine

  12. #12
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    Quote Originally Posted by ItsMe View Post
    In the VBA editor got to Tools>References and then tick

    Microsoft Office 14.0 Object Library

    from your available references list. Click OK. This is your library for early binding.

    some more info
    http://allenbrowne.com/ser-38.html
    found it just as you were typing that - sorry! but thanking you kindly!

  13. #13
    Ruegen's Avatar
    Ruegen is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    1,496
    ahhh so nice to see

    joy

    Click image for larger version. 

Name:	Capture.JPG 
Views:	12 
Size:	16.1 KB 
ID:	14653

  14. #14
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Cool......

Please reply to this thread with any new information or opinions.

Similar Threads

  1. how do I add the attachment to an email?
    By LanieB in forum Forms
    Replies: 2
    Last Post: 11-01-2013, 10:19 AM
  2. Email with attachment
    By Ganymede in forum Access
    Replies: 2
    Last Post: 06-01-2012, 01:59 PM
  3. Mailmerge an Email with an attachment
    By Baldeagle in forum Access
    Replies: 8
    Last Post: 05-21-2012, 02:21 PM
  4. Replies: 16
    Last Post: 04-30-2012, 07:12 AM
  5. email attachment from Access
    By Gandalf in forum Queries
    Replies: 0
    Last Post: 01-22-2009, 10:03 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums