Need to see if your shared folder is taking up space on your dropbox 👨‍💻? Find out how to check here.

Forum Discussion

smarta1's avatar
smarta1
Explorer | Level 3
6 years ago

load files whit excel vba

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.

6 Replies

  • Jay's avatar
    Jay
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    6 years ago

    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!

  • smarta1's avatar
    smarta1
    Explorer | Level 3
    6 years ago

    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.

  • Jay's avatar
    Jay
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    6 years ago

    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.

  • smarta1's avatar
    smarta1
    Explorer | Level 3
    6 years ago

    Hi Jay.

    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

            Debug.Print req.responseText

        End If

    End Sub

    Can you help me?

    Best regards.

  • Jay's avatar
    Jay
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    6 years ago

    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.

  • Greg-DB's avatar
    Greg-DB
    Icon for Dropbox Community Moderator rankDropbox Community Moderator
    6 years ago

    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.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X, Facebook or Instagram.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!