Hi team,
I don't profess to be any master of Excel, so when these things arrive I can generally write a best-effort macro to sort out any bulk updates, but this one has me stumped.
When we migrate our reports that connect to an OLEDB source and Cube they are coming across with the following two connection settings:
.RefreshOnFileOpen = True
.RefreshPeriod = 10
I need all of these in a workbook to be update to:
.RefreshOnFileOpen = False
.RefreshPeriod = 0
Recording a macro and changing one connection results in the following VB script:
Sub ChangeConn()
'
' ChangeConn Macro
'
'
With ActiveWorkbook.Connections("Connection").OLEDBConnection
.CommandText = Array("Something")
.CommandType = xlCmdCube
.Connection = Array( _
"OLEDB;Provider=MSOLAP.3;Persist Security Info=True;User ID="""";Initial Catalog=Something;Data Source=Something;Location=Something" _
, _
"Something;MDX Compatibility=1;Safety Options=2;MDX Missing Member Mode=Error" _
)
.RefreshOnFileOpen = False
.SavePassword = False
.SourceConnectionFile = ""
.MaxDrillthroughRecords = 1000
.ServerCredentialsMethod = xlCredentialsMethodIntegrated
.AlwaysUseConnectionFile = False
.RetrieveInOfficeUILang = False
.ServerFillColor = False
.ServerFontStyle = False
.ServerNumberFormat = False
.ServerTextColor = False
End With
With ActiveWorkbook.Connections("Connection")
.Name = "Connection"
.Description = ""
End With
End Sub
So I thought that the following Macro would work:
Sub FixConn()
For Each OLEDBConnection In ActiveWorkbook.Connections
.RefreshOnFileOpen = False
.RefreshPeriod = 0
Next OLEDBConnection
End Sub
But no... So I'm going to keep trying to figure this out, but if anyone here can help me that would be great.
[EDIT#1] Thanks to Andrew I'm a step closer and I'm pursuing this link here. Seems I was altering this object in the wrong place. :) http://msdn.microsoft.com/en-us/library/bb213295(office.12).aspx
[SOLUTION]
Sub ReFixConn()
For Each PivotCache In ActiveWorkbook.PivotCaches
With PivotCache
.RefreshOnFileOpen = False
.RefreshPeriod = 0
End With
Next PivotCache
End Sub