none
Reference files on Dropbox with VBA RRS feed

  • Question

  • Hello,

    I have an .xlsm file which need to refererence other .xlsx files on Dropbox in order to proceed some calculations

    I'm not the owner of Dropbox (admin). Files where just shared with me

    What's the best way to do it? Could you please send me a peace of code for the start....

    Thanks for help

    s.

    Friday, November 10, 2017 1:01 PM

All replies

  • I don't use Dropbox but I looked at this a while back.  You need to use curl to get the file using the file token.  I suggest you first do it manually using curl.  Once you can do it manually you can easily make a call to curl using VBA and Wscript.

    The curl command will look something like this:

    curl https://www.dropbox.com/sh/AAbbCCEeFF123?dl=1 -O -J -L

    • Edited by mogulman52 Friday, November 10, 2017 3:31 PM
    Friday, November 10, 2017 2:13 PM
  • Thanks for info. Could you please give me some more details (some kind of exmaple would be usefull)...
    Friday, November 10, 2017 6:40 PM
  • I don't use Dropbox so I can't do an example.  I use OneDrive.  Did you get curl command line working?  Give me the command line and I'll show you how to call it from VBA.  Just use a dummy file on your own account.  It needs to be a shared file.
    Saturday, November 11, 2017 2:09 PM
  • I noticed another recent posting had a shared dropbox file.  I dowloaded curl and put it my Program Files (x86) directory.  Here is the program to download file.  I put file in my C:\temp dir.

    Sub DownloadDropboxFile()
      Const CURLEXE As String = "C:\Program Files (x86)\curl-7.53.1\src\curl.exe"
      Const DOWNLOAD_DIR As String = "C:\Temp"
      Const PARAMS As String = " -O -J -L"
      Dim fileURL As String
      Dim cmd As String
      
      fileURL = "https://www.dropbox.com/s/7qn1dbp215o0m64/DATABASE.png?dl=0"
      cmd = """" & CURLEXE & """" & " """ & fileURL & """" & PARAMS
      ChDir DOWNLOAD_DIR ' Set Download directory
      If RunCmd(cmd, "Dropbox Download Failed") Then
        MsgBox "Download worked"
      End If
    End Sub
    
    Function RunCmd(cmd As String, errMsg As String) As Boolean
    
      Dim wsh As Object
      Dim waitOnReturn As Boolean
      Dim windowStyle As Integer
      Dim errorCode As Integer
      
      On Error GoTo Handler
    
      Set wsh = CreateObject("WScript.Shell")
      waitOnReturn = True
      windowStyle = 7
      errorCode = wsh.Run(cmd, windowStyle, waitOnReturn)
      If errorCode = 1 Then
        RunCmd = False
      Else
        RunCmd = True
      End If
      Exit Function
      
    Handler:
      Call MsgBox(Err.Number & ": " & Err.Description, vbOKOnly, errMsg)
      Err.Clear
      RunCmd = False
    End Function
    

    Saturday, November 11, 2017 6:35 PM
  • Thanks a lot! I'll be testing it in the evening as I'm at work now and let you know

    Monday, November 13, 2017 8:09 AM