Hi.
I would like to receive an example on how to upload a file (ie *.xlsm) to dropbox from excel using vba.
Thanks a lot.
Hi @smarta1, thanks for posting on the Community!
Are you trying to upload files to Dropbox directly using the Excel app, or via Office Online?
Keep me posted!
Hi Jay.
Thanks for your answer.
I am using MS Excel (Microsoft Office) on a Desktop with Windows 8.1 (No Office Online).
I would like to have a VBA routine to insert in my excel file (*.xlsm).
Best regards.
I'm not sure if it's possible to create a VBA script to upload to Dropbox directly, however, you can look into the Dropbox API documentation for more information to see if there is any possibility of doing so using the info there.
I asked because I found the following but I do not know if is complete:
Public Sub DB_PutFile(FileName As String)
Dim req As MSXML2.ServerXMLHTTP60
Dim strFile As String
Dim Pos1 As Integer
Dim Pos2 As Integer
Dim arg As String
Set req = New MSXML2.ServerXMLHTTP60
strFile= ReadBinary(FileName)
arg = "{""path"":""/" & FileName & """,""mode"":{"".tag"":""overwrite""},""autorename"":false,""mute"":true}"
req.Open "POST", "https://content.dropboxapi.com/2/files/upload", False
req.setRequestHeader "Authorization", "Bearer xxxxxxxxxxxxxxxx"
req.setRequestHeader "Content-Type", "application/octet-stream"
req.setRequestHeader "Content-length", Len(Result)
req.setRequestHeader "Dropbox-API-Arg", arg
req.setRequestHeader "User-Agent", "api-explorer-client"
req.send strFile
If req.Status = 200 Then
Debug.Print req.responseText
Else
'MsgBox req.Status & ": " & req.statusText
End If
End Sub
Can you help me?
It does look like some API calls are made there. I can move this thread to the API forum, however, bear in mind that we might not be able to assist with the VBA script as it isn't related to Dropbox itself.
@smarta1 The Dropbox API does offer the ability to programmatically upload files, such as by using /2/files/upload as referenced in the code you shared. Please refer to the documentation linked there for information on using that.
Give that a try and if something on the API isn't working expected, please share the error/output.