Hi,
I have a problem with automating and refreshing my TFS (Team Foundation Server addin tool for Excel). The code itself is actually working and running a public sub is also refreshing my input live.
However, when I want to automate this with an ontime code, it's not working. Giving the error "Cannot run the macro "macroname". The macro may not be available in this workbook or all macros may be disabled".
I've pasted the following code in Sheet2 (Microsoft Objects)
I've inserted a module with the following code run the UpdateTFS code per 10 minutes.
Any suggestions?
I have a problem with automating and refreshing my TFS (Team Foundation Server addin tool for Excel). The code itself is actually working and running a public sub is also refreshing my input live.
However, when I want to automate this with an ontime code, it's not working. Giving the error "Cannot run the macro "macroname". The macro may not be available in this workbook or all macros may be disabled".
I've pasted the following code in Sheet2 (Microsoft Objects)
Code:
Private Sub RefreshTeamQueryOnWorksheet(worksheetName As String)
Dim activeSheet As Worksheet
Dim teamQueryRange As Range
Dim refreshControl As CommandBarControl
Set refreshControl = FindTeamControl("IDC_REFRESH")
If refreshControl Is Nothing Then
MsgBox "Could not find Team Foundation commands in Ribbon. Please make sure that the Team Foundation Excel plugin is installed.", vbCritical
Exit Sub
End If
' Disable screen updating temporarily so that the user doesn’t see us selecting a range
Application.ScreenUpdating = False
' Capture the currently active sheet, we will need it later
Set activeSheet = ActiveWorkbook.activeSheet
Set teamQueryRange = Worksheets(worksheetName).ListObjects(1).Range
teamQueryRange.Worksheet.Select
teamQueryRange.Select
refreshControl.Execute
activeSheet.Select
Application.ScreenUpdating = True
End Sub
Code:
Private Function FindTeamControl(tagName As String) As CommandBarControl
Dim commandBar As commandBar
Dim teamCommandBar As commandBar
Dim control As CommandBarControl
For Each commandBar In Application.CommandBars
If commandBar.Name = "Team" Then
Set teamCommandBar = commandBar
Exit For
End If
Next
If Not teamCommandBar Is Nothing Then
For Each control In teamCommandBar.Controls
If InStr(1, control.Tag, tagName) Then
Set FindTeamControl = control
Exit Function
End If
Next
End If
End Function
Code:
Public Sub UpdateTFS()
RefreshTeamQueryOnWorksheet ("Sheet2")
End Sub
I've inserted a module with the following code run the UpdateTFS code per 10 minutes.
Code:
sub test()
Application.OnTime Now + TimeValue("00:10:00"), "UpdateTFS"
end sub
Any suggestions?