Solved

Access VB Download Files SharePoint 2013

Posted on 2016-09-10
11
49 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 84
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
 
LVL 17

Assisted Solution

by:xtermie
xtermie earned 125 total points (awarded by participants)
ID: 41795806
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 31

Accepted Solution

by:
Helen_Feddema earned 250 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 125 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 17

Expert Comment

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

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Technology opened people to different means of presenting information, but PowerPoint remains to be above competition. Know why PPT still works today.
This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
The viewer will learn how to  create a slide that will launch other presentations in Microsoft PowerPoint. In the finished slide, each item launches a new PowerPoint presentation and when each is finished it automatically comes back to this slide: …

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now