1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

  2. Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User


  3. When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Send a file to the dropbox with a macro

Discussion in 'VBA Macros' started by stefanoste78, Nov 8, 2018.

  1. stefanoste78

    stefanoste78 Member

    On dropbox there is the possibility of requesting files by creating a link for sending.

    There is someone who already has experience in sending files with this system automatically with a macro.

    the link I generated for sending is:
  2. stefanoste78

    stefanoste78 Member

    Can be this the code:

    Code (vb):
    'In VBA, go to Tools, References, then select the Microsoft XML from the list
    'store the folder as a variable so you don't have to recheck it each time
    Public strDropBoxFolder As String
    'This locates and returns the full path of the DropBox folder
    Public Function DropBoxFolder() As String
    Dim DBhost As String
    Dim strInput As String
    Dim DBPath As String
    On Error GoTo Error_Handler
    'If the folder has already been found, don't recheck it, just use the stored variable
    If strDropBoxFolder <> "" Then
    DropBoxFolder = strDropBoxFolder
    Exit Function
    End If
    'otherwise, go find it.
    ' find the host.db file
    DBhost = CStr(Environ("USERPROFILE") & "\AppData\Roaming\Dropbox\host.db")
    If Dir(DBhost) <> "" Then
    Open DBhost For Input Access Read As #1
    'read the host.db file
    Line Input #1, strInput
    Close #1
    'decode from Base64
    strInput = StrConv(DecodeBase64(strInput), vbUnicode)
    'ignore the first line and extract the file path by looking drive name such as C:\
    DBPath = Mid(strInput, InStr(strInput, ":\") - 1)
    'return the result
    DropBoxFolder = DBPath
    'store the result for future use
    strDropBoxFolder = DBPath
    'file not found and error are handled the same way
    On Error Resume Next
    strDropBoxFolder = ""
    End If
    End Function
    Private Function DecodeBase64(ByVal strData As String) As Byte()
    Dim objXML As MSXML2.DOMDocument
    Dim objNode As MSXML2.IXMLDOMElement
    ' help from MSXML
    Set objXML = New MSXML2.DOMDocument
    Set objNode = objXML.createElement("b64")
    objNode.DataType = "bin.base64"
    objNode.Text = strData
    DecodeBase64 = objNode.nodeTypedValue
    ' thanks, bye
    Set objNode = Nothing
    Set objXML = Nothing
    End Function
  3. stefanoste78

    stefanoste78 Member

  4. charlesdh

    charlesdh New Member

    If you have "Dropbox" on your desk top and have it in your system tray.
    See images on how to set it up.
    I recorded a macro that will save the file to "DropBox".
    You need to change this code to your system.
    Code (vb):

    Sub dropboxTest()
    ' Macro1 Macro recorded''

        ChDir "C:\Users\charlesharmon\Dropbox"
        ActiveWorkbook.SaveAs Filename:= _
            "C:\Users\charlesharmon\Dropbox\Booktestdropbox1.xlsm", FileFormat:= _
            xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
    End Sub
    You need to be logged in "DropBox".

    Attached Files:

Share This Page