Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub ButtonClick1()
- Dim addin As Office.COMAddIn
- Dim automationObject As Object
- Dim error As String
- Dim error1 As String
- Dim Result As Boolean
- Dim ReportResult As String
- Dim LastRowLeft As String
- Dim LastRowRight As String
- Dim sheetname As String
- sheetname = ActiveSheet.Name
- For Each addin In Application.COMAddIns
- If addin.Description = "Enabler4Excel" Then
- Set automationObject = addin.Object
- End If
- Next addin
- Result = automationObject.LogIn("myemail.org", "mypassword", "https://login.salesforce.com", error)
- If Result = False Then
- MsgBox error
- End
- End If
- ReportResult = automationObject.RunReport("00Od0000004yulX", error1)
- Dim wb As Excel.Workbook
- Set wb = ThisWorkbook
- Set ws = wb.Sheets("2016 Incidents Dashboard")
- With ws.QueryTables.Add(Connection:="TEXT;" & ReportResult, Destination:=ws.Range("A1"))
- .TextFileParseType = xlDelimited
- .TextFileCommaDelimiter = True
- .RefreshStyle = xlOverwriteCells
- .Refresh
- End With
- Result1 = automationObject.LogOut()
- Worksheets("2016 Incidents Dashboard").Activate
- LastRowLeft = ws.Range("A" & ws.Rows.Count).End(xlUp).Row
- LastRowRight = ws.Range("M" & ws.Rows.Count).End(xlUp).Row
- Range("M" & LastRowRight & ":U" & LastRowRight).Select
- Selection.AutoFill Destination:=Range("M" & LastRowRight & ":U" & LastRowLeft)
- ActiveWorkbook.RefreshAll
- Worksheets(sheetname).Activate
- End Sub
- Set automationObject = FindEnablerAddin()
- ' [...]
- Private Function FindEnablerAddin() As Object
- For Each addin In Application.COMAddIns
- If addin.Description = "Enabler4Excel" Then
- Set FindEnablerAddin = addin.Object
- Exit Function
- End If
- Next addin
- 'FindEnablerAddin should be Nothing
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement