Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1068455
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:17:25+00:00 2026-05-16T20:17:25+00:00

I don’t profess to be any master of Excel, so when these things arrive

  • 0

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
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T20:17:25+00:00Added an answer on May 16, 2026 at 8:17 pm

    You forgot the With block:

    Sub FixConn()
     For Each OLEDBConnection In ActiveWorkbook.Connections
      With OLEDBConnection
       .RefreshOnFileOpen = False
       .RefreshPeriod = 0
      End With
     Next OLEDBConnection
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Don't be afraid to use any technical jargon or low-level explanations for things, please.
(Don't know if this is strictly on-topic, but I don't see any better Stack
Don't know if anyone can help me with this or if it's even possible.
Don't have much to say, just can get into the event handler. XAML: <Grid>
Don't these two mean the same thing, first get the value and then increment?
Don't ask why, but is there any way to suppress a failed linking error?
I don't have any experience in updating a Rails app and when I google
I don't have much PHP experience and I want to know how to best
Don't ask me why but i can't use this method because I need to
Don't know why I can't reply to people on here with only a small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.