ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Please Help: Upload a File and save it at a specific location (https://www.excelbanter.com/excel-programming/434364-please-help-upload-file-save-specific-location.html)

Sam

Please Help: Upload a File and save it at a specific location
 
Hi All,

Is there a way to upload a file through excel userform? I am looking to
upload a PDF file throug a userform I have designed.

For eg, Designing a "Browse" button on the form, which on clicking will
display a window where users can select the file they want to submit and
upload it? So once they select a file and click "Submit" button on the
userform, the selected file is saved at a specific location on a shared drive.

Is this possible?

Thanks in Advance

Jacob Skaria

Please Help: Upload a File and save it at a specific location
 
Hi Sam

On button click you can try the below two options

Sub Macro1()
Dim varFile As Variant, strDestFolder As String

strDestFolder = "J:\Files"
varFile = Application.GetOpenFilename
If varFile = False Then Exit Sub

'Copy File
FileCopy varFile, strDestFolder & _
Mid(varFile, InStrRev(varFile, Application.PathSeparator))

End Sub

OR if you want to filter this by PDF files you can try the below macro

Sub Macro2()
Dim varFile As Variant, strDestFolder As String

strDestFolder = "J:\Files"

With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Filters.Add "Adobe Acrobat", "*.pdf", 1
.InitialFileName = "C:\"
.Show
If .SelectedItems.Count = 0 Then Exit Sub
varFile = .SelectedItems(1)
End With

'Copy File
FileCopy varFile, strDestFolder & _
Mid(varFile, InStrRev(varFile, Application.PathSeparator))

End Sub



If this post helps click Yes
---------------
Jacob Skaria


"sam" wrote:

Hi All,

Is there a way to upload a file through excel userform? I am looking to
upload a PDF file throug a userform I have designed.

For eg, Designing a "Browse" button on the form, which on clicking will
display a window where users can select the file they want to submit and
upload it? So once they select a file and click "Submit" button on the
userform, the selected file is saved at a specific location on a shared drive.

Is this possible?

Thanks in Advance


Sam

Please Help: Upload a File and save it at a specific location
 
Thanks a lot for your help Jacob, Is it possible to desin it such that they
can only upload pdf files and no other format? I want them to see only pdf
files, so they cannot upload files with any other format..

Thanks in advance

"Jacob Skaria" wrote:

Hi Sam

On button click you can try the below two options

Sub Macro1()
Dim varFile As Variant, strDestFolder As String

strDestFolder = "J:\Files"
varFile = Application.GetOpenFilename
If varFile = False Then Exit Sub

'Copy File
FileCopy varFile, strDestFolder & _
Mid(varFile, InStrRev(varFile, Application.PathSeparator))

End Sub

OR if you want to filter this by PDF files you can try the below macro

Sub Macro2()
Dim varFile As Variant, strDestFolder As String

strDestFolder = "J:\Files"

With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Filters.Add "Adobe Acrobat", "*.pdf", 1
.InitialFileName = "C:\"
.Show
If .SelectedItems.Count = 0 Then Exit Sub
varFile = .SelectedItems(1)
End With

'Copy File
FileCopy varFile, strDestFolder & _
Mid(varFile, InStrRev(varFile, Application.PathSeparator))

End Sub



If this post helps click Yes
---------------
Jacob Skaria


"sam" wrote:

Hi All,

Is there a way to upload a file through excel userform? I am looking to
upload a PDF file throug a userform I have designed.

For eg, Designing a "Browse" button on the form, which on clicking will
display a window where users can select the file they want to submit and
upload it? So once they select a file and click "Submit" button on the
userform, the selected file is saved at a specific location on a shared drive.

Is this possible?

Thanks in Advance


JLGWhiz[_2_]

Please Help: Upload a File and save it at a specific location
 
It looks to me like that is what Macro2 does. Did you read the post where
it says:

OR if you want to filter this by PDF files you can try the below macro



"sam" wrote in message
...
Thanks a lot for your help Jacob, Is it possible to desin it such that
they
can only upload pdf files and no other format? I want them to see only pdf
files, so they cannot upload files with any other format..

Thanks in advance

"Jacob Skaria" wrote:

Hi Sam

On button click you can try the below two options

Sub Macro1()
Dim varFile As Variant, strDestFolder As String

strDestFolder = "J:\Files"
varFile = Application.GetOpenFilename
If varFile = False Then Exit Sub

'Copy File
FileCopy varFile, strDestFolder & _
Mid(varFile, InStrRev(varFile, Application.PathSeparator))

End Sub

OR if you want to filter this by PDF files you can try the below macro

Sub Macro2()
Dim varFile As Variant, strDestFolder As String

strDestFolder = "J:\Files"

With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Filters.Add "Adobe Acrobat", "*.pdf", 1
.InitialFileName = "C:\"
.Show
If .SelectedItems.Count = 0 Then Exit Sub
varFile = .SelectedItems(1)
End With

'Copy File
FileCopy varFile, strDestFolder & _
Mid(varFile, InStrRev(varFile, Application.PathSeparator))

End Sub



If this post helps click Yes
---------------
Jacob Skaria


"sam" wrote:

Hi All,

Is there a way to upload a file through excel userform? I am looking to
upload a PDF file throug a userform I have designed.

For eg, Designing a "Browse" button on the form, which on clicking will
display a window where users can select the file they want to submit
and
upload it? So once they select a file and click "Submit" button on the
userform, the selected file is saved at a specific location on a shared
drive.

Is this possible?

Thanks in Advance




Sam

Please Help: Upload a File and save it at a specific location
 
Yes, But that one still lets user select "All Files" from Files of type
dropdown in file open window, So once they select "All Files" they are able
to select word, excel files

"JLGWhiz" wrote:

It looks to me like that is what Macro2 does. Did you read the post where
it says:

OR if you want to filter this by PDF files you can try the below macro



"sam" wrote in message
...
Thanks a lot for your help Jacob, Is it possible to desin it such that
they
can only upload pdf files and no other format? I want them to see only pdf
files, so they cannot upload files with any other format..

Thanks in advance

"Jacob Skaria" wrote:

Hi Sam

On button click you can try the below two options

Sub Macro1()
Dim varFile As Variant, strDestFolder As String

strDestFolder = "J:\Files"
varFile = Application.GetOpenFilename
If varFile = False Then Exit Sub

'Copy File
FileCopy varFile, strDestFolder & _
Mid(varFile, InStrRev(varFile, Application.PathSeparator))

End Sub

OR if you want to filter this by PDF files you can try the below macro

Sub Macro2()
Dim varFile As Variant, strDestFolder As String

strDestFolder = "J:\Files"

With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Filters.Add "Adobe Acrobat", "*.pdf", 1
.InitialFileName = "C:\"
.Show
If .SelectedItems.Count = 0 Then Exit Sub
varFile = .SelectedItems(1)
End With

'Copy File
FileCopy varFile, strDestFolder & _
Mid(varFile, InStrRev(varFile, Application.PathSeparator))

End Sub



If this post helps click Yes
---------------
Jacob Skaria


"sam" wrote:

Hi All,

Is there a way to upload a file through excel userform? I am looking to
upload a PDF file throug a userform I have designed.

For eg, Designing a "Browse" button on the form, which on clicking will
display a window where users can select the file they want to submit
and
upload it? So once they select a file and click "Submit" button on the
userform, the selected file is saved at a specific location on a shared
drive.

Is this possible?

Thanks in Advance





JP[_4_]

Please Help: Upload a File and save it at a specific location
 
If you use the Application.GetOpenFilename method, you can limit the
selection to PDFs only.

--JP

On Oct 5, 10:58*am, sam wrote:
Yes, But that one still lets user select "All Files" from Files of type
dropdown in file open window, So once they select "All Files" they are able
to select word, excel files



JLGWhiz[_2_]

Please Help: Upload a File and save it at a specific location
 
If you are going to use the dialog box for the user to select from, then you
will not have much choice about how the user manipulates it. But the second
macro limits the choices for most novice users. If it does not have a .pdf
extension, it will not show in the selection window, unless the user knows
to click the file type drop down. Why would they want to do that when the
PDF selections should be right in front of them?

But you can fix that probability with code that if they select a file < to
..pdf then a message appears that they picked the wrong file type and exit
out of the sub.


"sam" wrote in message
...
Yes, But that one still lets user select "All Files" from Files of type
dropdown in file open window, So once they select "All Files" they are
able
to select word, excel files

"JLGWhiz" wrote:

It looks to me like that is what Macro2 does. Did you read the post
where
it says:

OR if you want to filter this by PDF files you can try the below macro



"sam" wrote in message
...
Thanks a lot for your help Jacob, Is it possible to desin it such that
they
can only upload pdf files and no other format? I want them to see only
pdf
files, so they cannot upload files with any other format..

Thanks in advance

"Jacob Skaria" wrote:

Hi Sam

On button click you can try the below two options

Sub Macro1()
Dim varFile As Variant, strDestFolder As String

strDestFolder = "J:\Files"
varFile = Application.GetOpenFilename
If varFile = False Then Exit Sub

'Copy File
FileCopy varFile, strDestFolder & _
Mid(varFile, InStrRev(varFile, Application.PathSeparator))

End Sub

OR if you want to filter this by PDF files you can try the below macro

Sub Macro2()
Dim varFile As Variant, strDestFolder As String

strDestFolder = "J:\Files"

With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
.Filters.Add "Adobe Acrobat", "*.pdf", 1
.InitialFileName = "C:\"
.Show
If .SelectedItems.Count = 0 Then Exit Sub
varFile = .SelectedItems(1)
End With

'Copy File
FileCopy varFile, strDestFolder & _
Mid(varFile, InStrRev(varFile, Application.PathSeparator))

End Sub



If this post helps click Yes
---------------
Jacob Skaria


"sam" wrote:

Hi All,

Is there a way to upload a file through excel userform? I am looking
to
upload a PDF file throug a userform I have designed.

For eg, Designing a "Browse" button on the form, which on clicking
will
display a window where users can select the file they want to submit
and
upload it? So once they select a file and click "Submit" button on
the
userform, the selected file is saved at a specific location on a
shared
drive.

Is this possible?

Thanks in Advance








All times are GMT +1. The time now is 07:35 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com