Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default 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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default 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

  #3   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default 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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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



  #5   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default 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






  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 897
Default 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


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,565
Default 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






Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Macro to Save File to specific location when closing paankadu Excel Discussion (Misc queries) 3 October 26th 09 11:52 PM
Auto save Spread sheet as htm to a specific location Saving is tough Excel Discussion (Misc queries) 0 October 29th 08 03:46 PM
Macro to Save As to a specific location Char4500 Excel Programming 2 October 9th 06 04:18 PM
Save to specific location LB79 Excel Discussion (Misc queries) 2 August 25th 05 11:02 AM
Save File to Another Directory, but not change Users File Save location Mike Knight Excel Programming 1 May 28th 04 09:06 PM


All times are GMT +1. The time now is 04:55 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"