Consulting

Results 1 to 3 of 3

Thread: Insert button for upload documents

  1. #1
    VBAX Newbie
    Joined
    Aug 2011
    Posts
    4
    Location

    Insert button for upload documents

    I want to create a report template by using excel for people who are in poor countries and don't know much about the computer etc.

    So, I want make my worksheet simpler and easy for them to use. And it need to be work in the 'compatibility mode', the old excel version.

    Basically, I want to create a button "upload file". It will enable them to attach a photo or word documents to the excel spreadsheet. I know how to do it by click the buttons. Under 'insert object', choose 'Create from File'. Tick the 'Display as Icon'. Then click "Browse'. By selecting the right documents, it's done. They only need to send back the excel document rather than the excel document and other attachments such as .jpgs and .docs.

    Now, by saving those people few steps, I want create this "upload file" button. When user click on the button, the "Browse" window will jump up directly.

    I don't know how to use write VBA code/Macro to achieve this. Please help!!

    Thank you so much in advance.

  2. #2
    VBAX Regular
    Joined
    Sep 2008
    Location
    Sheffield
    Posts
    72
    Location

    Exclamation

    The below VB will do it...... a click will open a find file dialogue then you can embed a file into a spreadsheet.

    See attached Spreadsheet as example .....
    ______________________________________________________
    Private Sub btnAddFile_Click()
    Dim vFile As Variant 
         vFile = Application.GetOpenFilename("All Files,*.*", Title:="Find file to insert") 
         If LCase(vFile) = "false" Then 
    Exit Sub 
         ActiveSheet.OLEObjects.Add Filename:=vFile, Link:=False, DisplayAsIcon:=True, IconLabel:=vFile
    End Sub
    Attached Files Attached Files
    Last edited by Aussiebear; 04-06-2023 at 09:15 PM. Reason: Adjusted the code tags

  3. #3
    VBAX Newbie
    Joined
    Aug 2011
    Posts
    4
    Location

    Thumbs up That works! Thank you.

    Thank you ads_3131. That works! Great! I really appreciated.


    Quote Originally Posted by ads_3131
    The below VB will do it...... a click will open a find file dialogue then you can embed a file into a spreadsheet.

    See attached Spreadsheet as example .....
    ______________________________________________________
    Private Sub btnAddFile_Click()
    Dim vFile As Variant 
    vFile = Application.GetOpenFilename("All Files,*.*", Title:="Find file to insert") 
    If LCase(vFile) = "false" Then 
    Exit Sub 
    ActiveSheet.OLEObjects.Add Filename:=vFile, Link:=False, DisplayAsIcon:=True, IconLabel:=vFile
    End Sub
    Last edited by Aussiebear; 04-06-2023 at 09:16 PM. Reason: Adjusted the code tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •