+ Reply to Thread
Results 1 to 10 of 10

Userform (Browse & pick PDF file, save it)

Hybrid View

rizkifatah Userform (Browse & pick PDF... 07-18-2019, 03:06 AM
dotchiejack Re: Userform (Browse & pick... 07-18-2019, 03:35 AM
:) Sixthsense :) Re: Userform (Browse & pick... 07-18-2019, 03:35 AM
rizkifatah Re: Userform (Browse & pick... 07-18-2019, 04:42 AM
rizkifatah Re: Userform (Browse & pick... 07-18-2019, 04:58 AM
:) Sixthsense :) Re: Userform (Browse & pick... 07-18-2019, 05:11 AM
rizkifatah Re: Userform (Browse & pick... 07-18-2019, 06:32 AM
:) Sixthsense :) Re: Userform (Browse & pick... 07-18-2019, 06:39 AM
rizkifatah Re: Userform (Browse & pick... 07-18-2019, 08:09 AM
:) Sixthsense :) Re: Userform (Browse & pick... 07-19-2019, 12:11 AM
  1. #1
    Registered User
    Join Date
    07-18-2019
    Location
    Oman
    MS-Off Ver
    office business 2016
    Posts
    5

    Userform (Browse & pick PDF file, save it)

    Please give assists on my case, since I am new on coding.
    I do have userform which had Application.FileDialog(msoFileDialogFilePicker) for pdf file.
    The question is what is the script for saving file selected pdf file on specific folder when I click Submit CommandButton.

    Untitled.jpg

    I hope somebody could help me finish this coding.

  2. #2
    Valued Forum Contributor dotchiejack's Avatar
    Join Date
    05-21-2015
    Location
    Antwerp,Belgium
    MS-Off Ver
    2016
    Posts
    507

    Re: Userform (Browse & pick PDF file, save it)

    Post a small example of your excel file without sensitive data, make sure it's clear what you want to achieve.
    Don't post a picture, pictures belong in a photoshop forum and not in an excel forum.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Userform (Browse & pick PDF file, save it)

    Sub UploadFile()
    Dim DialogBox As FileDialog, sFileLocation As String, sSaveLocation As String
    
    'Change your Destination Location Here...
    sSaveLocation = "D:\"
    
    Set DialogBox = Application.FileDialog(msoFileDialogOpen)
    
    With DialogBox
        .AllowMultiSelect = False
        .Filters.Clear
        .Filters.Add "PDF File", "*.PDF"
        .Title = "Select PDF file"
        If .Show = -1 Then
           sFileLocation = DialogBox.SelectedItems(1)
           CreateObject("scripting.filesystemobject").CopyFile sFileLocation, sSaveLocation
           MsgBox "File Uploaded Successfully", vbInformation, "Task Completed"
        Else
            MsgBox "No File Chosen", vbInformation, "File Not Selected"
        End If
    End With
    
    End Sub


    If your problem is solved, then please mark the thread as SOLVED>>Above your first post>>Thread Tools>>
    Mark your thread as Solved


    If the suggestion helps you, then Click *below to Add Reputation

  4. #4
    Registered User
    Join Date
    07-18-2019
    Location
    Oman
    MS-Off Ver
    office business 2016
    Posts
    5

    Re: Userform (Browse & pick PDF file, save it)

    It is kind a working Sixthsense

    Thank you very much brother.

  5. #5
    Registered User
    Join Date
    07-18-2019
    Location
    Oman
    MS-Off Ver
    office business 2016
    Posts
    5

    Re: Userform (Browse & pick PDF file, save it)

    Could we also change the name of the new copied files?

  6. #6
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Userform (Browse & pick PDF file, save it)

    Replace this

    'Change your Destination Location Here...
    sSaveLocation = "D:\"
    With

    'Change your Destination Location Here...
    sSaveLocation = "D:\" & "YourFileName" & ".PDF"

  7. #7
    Registered User
    Join Date
    07-18-2019
    Location
    Oman
    MS-Off Ver
    office business 2016
    Posts
    5

    Re: Userform (Browse & pick PDF file, save it)

    Thanks again,

    Now for the last thing, I need to put Hyperlink on value entered to the file path.
    Could I made this automatically from userform as well?

  8. #8
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Userform (Browse & pick PDF file, save it)

    Sub UploadFile()
    Dim DialogBox As FileDialog, sFileLocation As String, sSaveLocation As String
    
    'Change your Destination Location Here...
    sSaveLocation = "D:\" & "YourFileName" & ".PDF"
    
    Set DialogBox = Application.FileDialog(msoFileDialogOpen)
    
    With DialogBox
        .AllowMultiSelect = False
        .Filters.Clear
        .Filters.Add "PDF File", "*.PDF"
        .Title = "Select PDF file"
        If .Show = -1 Then
           sFileLocation = DialogBox.SelectedItems(1)
           CreateObject("scripting.filesystemobject").CopyFile sFileLocation, sSaveLocation
           
           'Hyperlink Added Here...
           'Change A1 To your desired cell in your coding
           ActiveSheet.Hyperlinks.Add Anchor:=Range("A1"), Address:=sSaveLocation, TextToDisplay:="Click To View"
    
           MsgBox "File Uploaded Successfully", vbInformation, "Task Completed"
        Else
            MsgBox "No File Chosen", vbInformation, "File Not Selected"
        End If
    End With
    
    End Sub

  9. #9
    Registered User
    Join Date
    07-18-2019
    Location
    Oman
    MS-Off Ver
    office business 2016
    Posts
    5

    Re: Userform (Browse & pick PDF file, save it)

    Quote Originally Posted by :) Sixthsense :) View Post
    Sub UploadFile()
    Dim DialogBox As FileDialog, sFileLocation As String, sSaveLocation As String
    
    'Change your Destination Location Here...
    sSaveLocation = "D:\" & "YourFileName" & ".PDF"
    
    Set DialogBox = Application.FileDialog(msoFileDialogOpen)
    
    With DialogBox
        .AllowMultiSelect = False
        .Filters.Clear
        .Filters.Add "PDF File", "*.PDF"
        .Title = "Select PDF file"
        If .Show = -1 Then
           sFileLocation = DialogBox.SelectedItems(1)
           CreateObject("scripting.filesystemobject").CopyFile sFileLocation, sSaveLocation
           
           'Hyperlink Added Here...
           'Change A1 To your desired cell in your coding
           ActiveSheet.Hyperlinks.Add Anchor:=Range("A1"), Address:=sSaveLocation, TextToDisplay:="Click To View"
    
           MsgBox "File Uploaded Successfully", vbInformation, "Task Completed"
        Else
            MsgBox "No File Chosen", vbInformation, "File Not Selected"
        End If
    End With
    
    End Sub
    Can we set the range not to specific cells? because if we put specific cell it will be replace for the next file saved.

  10. #10
    Forum Guru :) Sixthsense :)'s Avatar
    Join Date
    01-01-2012
    Location
    India>Tamilnadu>Chennai
    MS-Off Ver
    2003 To 2010
    Posts
    12,788

    Re: Userform (Browse & pick PDF file, save it)

    Quote Originally Posted by rizkifatah View Post
    Can we set the range not to specific cells? because if we put specific cell it will be replace for the next file saved.
    Sub UploadFile()
    Dim DialogBox As FileDialog, sFileLocation As String, sSaveLocation As String
    Dim r As Range
    
    'Change your Destination Location Here...
    sSaveLocation = "D:\" & "YourFileName" & ".PDF"
    
    Set DialogBox = Application.FileDialog(msoFileDialogOpen)
    
    With DialogBox
        .AllowMultiSelect = False
        .Filters.Clear
        .Filters.Add "PDF File", "*.PDF"
        .Title = "Select PDF file"
        If .Show = -1 Then
            sFileLocation = DialogBox.SelectedItems(1)
            CreateObject("scripting.filesystemobject").CopyFile sFileLocation, sSaveLocation
           
           'Hyperlink Added Here...
           'Change A1 To your desired cell in your coding
            For Each r In Range("A1:B15").Cells
                ActiveSheet.Hyperlinks.Add Anchor:=r, Address:=sSaveLocation, TextToDisplay:="Click To View"
            Next r
    
           MsgBox "File Uploaded Successfully", vbInformation, "Task Completed"
        Else
            MsgBox "No File Chosen", vbInformation, "File Not Selected"
        End If
    End With
    
    End Sub

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] To browse to a directory to save a file
    By Ravana in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-10-2016, 11:17 AM
  2. [SOLVED] How to Browse for a file from within a userform
    By j_Southern in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-27-2015, 06:19 PM
  3. Browse for a file and embed it in a userform to open in the future
    By chin67326 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 08-13-2014, 03:07 AM
  4. How to browse the path for the input files and save the output using a userform
    By priyankaseshadri in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-22-2014, 03:14 PM
  5. Userform image browse folder, show preview and save to range
    By Mehmet82 in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 12-04-2013, 12:47 PM
  6. How to browse & Attach a file to a userform in Excel?
    By rajat518 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-12-2013, 05:04 AM
  7. [SOLVED] Browse and attach file in a UserForm
    By Jeroen Kluytmans in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-07-2005, 06:06 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1