Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Access VB Download Files SharePoint 2013

Posted on 2016-09-10
11
Medium Priority
?
112 Views
Last Modified: 2016-10-09
I'm trying to download a file from SP 2013 using a button on an Access form. Can example code be provided. Thanks
0
Comment
Question by:shieldsco
11 Comments
 
LVL 85
ID: 41793293
Do you have code that you've tried, but it didn't work? If so then post that and let us know what did not work, and we'll try to help. We're not really here to do your work for you, but rather to help you when you get stuck.
0
 

Author Comment

by:shieldsco
ID: 41793304
I got the code to work below but I would like to use a wild card (*) for any Excel file in the SP Folder. There will always only be one Excel file in the SP Folder.

On Error GoTo errHere
 
Dim strQRY As String
 
Dim strHTTP As String
Dim strFileToSave As String
 
strHTTP = "https://asfr.hhh.net/OF/OFSPO/hhsfmg/mwwg/Data%20Call%20%20DDA/2016%20September%20DDA%20Data%20Call.xlsx"
strFileToSave = "C:\Users\shieldsco\Documents\Vince.xlsx"
 
If fnDownloadHTTP(strHTTP, strFileToSave) = False Then      ' -- downlaod the file
    MsgBox "File DL failed. Make sure folder exist"
    GoTo ExitHere
End If
 
MsgBox "All files downloaded"
 
ExitHere:
    Exit Sub
errHere:
    MsgBox "Error"
    Resume ExitHere

Open in new window

0
 

Author Comment

by:shieldsco
ID: 41793308
I would like to download any file that has the xlxs extension in the SP folder
0
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
LVL 18

Assisted Solution

by:xtermie
xtermie earned 500 total points (awarded by participants)
ID: 41795806
0
 
LVL 31

Accepted Solution

by:
Helen Feddema earned 1000 total points (awarded by participants)
ID: 41796081
Here is some code using the FileDialog object to select an Excel workbook for further processing:

Public Function SelectFile() As String
'Requires Office XP (2002) or higher
'Requires a reference to the Microsoft Office Object Library
'Created by Helen Feddema 28-Oct-2012
'Last modified by Helen Feddema 28-Oct-2012

On Error GoTo ErrorHandler

   Dim fd As Office.FileDialog
   Dim varSelectedItem As Variant
   Dim strFileNameAndPath As String
   
   'Create a FileDialog object as a File Picker dialog box.
   Set fd = Application.FileDialog(msoFileDialogFilePicker)
   
   With fd
      'Set AllowMultiSelect to True to allow selection of multiple files
      .AllowMultiSelect = False
      .Title = "Browse for File"
      .ButtonName = "Select"
      .Filters.Clear
      .Filters.Add "Documents", "*.xlsx; *.xlsm", 1
      .InitialView = msoFileDialogViewDetails
      If .Show = -1 Then
         'Get selected item in the FileDialogSelectedItems collection
         'Have to use collection even if just one item is selected
         For Each varSelectedItem In .SelectedItems
            strFileNameAndPath = CStr(varSelectedItem)
         Next varSelectedItem
      Else
         Debug.Print "User pressed Cancel"
         strFileNameAndPath = ""
      End If
   End With
   
   SelectFile = strFileNameAndPath
   
ErrorHandlerExit:
   Set fd = Nothing
   Exit Function

ErrorHandler:
   MsgBox "Error No: " & Err.Number _
      & " in SelectFile procedure; " _
      & "Description: " & Err.Description
   Resume ErrorHandlerExit

End Function

Open in new window

0
 

Assisted Solution

by:shieldsco
shieldsco earned 500 total points (awarded by participants)
ID: 41796119
My code works...trying to download the file with the xlsx extension:

strHTTP = "https://asfr.hhh.net/OF/OFSPO/hhsfmg/mwwg/Data%20Call%20%20DDA/2016%20September%20DDA%20Data%20Call.xlsx

Open in new window

0
 

Author Comment

by:shieldsco
ID: 41799785
Thanks
0
 

Author Comment

by:shieldsco
ID: 41807221
I got the code to work below but I would like to use a wild card (*) for any Excel file in the SP Folder. There will always only be one Excel file in the SP Folder.
0
 
LVL 18

Expert Comment

by:xtermie
ID: 41835691
good comments made and solutions proposed
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft has changed the look and feel of Azure AD and Microsoft account sign-in pages so that you will have a more unified look and feel when moving between the two interfaces.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

972 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question