<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>tim laqua dot com &#187; excel 2007</title>
	<atom:link href="http://timlaqua.com/tag/excel-2007/feed/" rel="self" type="application/rss+xml" />
	<link>http://timlaqua.com</link>
	<description>Thoughts and Code from Tim Laqua</description>
	<lastBuildDate>Fri, 16 Mar 2012 16:48:05 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Excel 2007 Hangs When Trying to Edit an OLAP Cube Filter</title>
		<link>http://timlaqua.com/2010/04/excel-2007-hangs-when-trying-to-edit-an-olap-cube-filter/</link>
		<comments>http://timlaqua.com/2010/04/excel-2007-hangs-when-trying-to-edit-an-olap-cube-filter/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 03:38:16 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Scripts & Code]]></category>
		<category><![CDATA[analysis services]]></category>
		<category><![CDATA[bi]]></category>
		<category><![CDATA[business intelligence]]></category>
		<category><![CDATA[excel 2007]]></category>
		<category><![CDATA[pivot table]]></category>
		<category><![CDATA[ssas]]></category>
		<category><![CDATA[xmla]]></category>

		<guid isPermaLink="false">http://timlaqua.com/?p=371</guid>
		<description><![CDATA[Ok, it doesn't hang every time you try to edit an OLAP cube filter, but sometimes - it appears to. In reality, I've never seen it permanently hang - just kind of go away for a while. Here's the basic symptom that the business will report to you: "Excel freezes (or hangs) when I try [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, it doesn't hang every time you try to edit an OLAP cube filter, but sometimes - it appears to.  In reality, I've never seen it permanently hang - just kind of go away for a while.  Here's the basic symptom that the business will report to you:</p>
<p><em>"Excel freezes (or hangs) when I try to change this filter"</em><br />
<a href="http://timlaqua.com/wp-content/uploads/2010/04/DeliveryDate-Date-Broken.png"><img src="http://timlaqua.com/wp-content/uploads/2010/04/DeliveryDate-Date-Broken.png" alt="" title="DeliveryDate-Date-Broken" width="352" height="351" class="alignnone size-full wp-image-373" /></a></p>
<p>Most of us have seen this at one point or another and shrugged it off as a busy time or processing is going on or there are cats clogging up the tubes, etc.  Tonight, I finally decided to figure out what's causing it.<br />
<span id="more-371"></span><br />
When you have an OLAP cube filter in your pivot table and expand the items list to select your filter items, Excel fires a bunch of Discover commands at the cube (these are pretty light in most cases).  If you don't have anything selected yet (so you just have the default member selected) Excel isn't doing much work here and the list pops right up.  Here's two basic flow examples for what discover commands are fired off when you DO have an item selected:</p>
<p>If you have one level 1 member selected</p>
<ol>
<li>MDSCHEMA_CUBES (whatever cube you're connected to)</li>
<li>MDSCHEMA_CUBES (again, same thing)</li>
<li>MDSCHEMA_MEMBERS (LEVEL_UNIQUE_NAME of the filter), no TREE_OP</li>
<li>MDSCHEMA_MEMBERS (MEMBER_UNIQUE_NAME of the selected member) TREE_OP 4, only immediate parent</li>
<li>MDSCHEMA_MEMBERS (MEMBER_UNIQUE_NAME of the selected member's parent) TREE_OP 8, returns itself</li>
<li>MDSCHEMA_MEMBERS (MEMBER_UNIQUE_NAME of the selected member's parent) TREE_OP 1, returns all children</li>
</ol>
<p>If you have one level 2 member selected in a hierarchy</p>
<ol>
<li>MDSCHEMA_CUBES (whatever cube you're connected to)</li>
<li>MDSCHEMA_CUBES (again, same thing)</li>
<li>MDSCHEMA_MEMBERS (LEVEL_UNIQUE_NAME of the filter), no TREE_OP</li>
<li>MDSCHEMA_MEMBERS (MEMBER_UNIQUE_NAME of the selected member) TREE_OP 4, only immediate parent</li>
<li>MDSCHEMA_MEMBERS (MEMBER_UNIQUE_NAME of the selected member's parent's parent)  TREE_OP 4, immediate parent</li>
<li>MDSCHEMA_MEMBERS (MEMBER_UNIQUE_NAME of the selected member's parent's parent) TREE_OP 8, returns itself</li>
<li>MDSCHEMA_MEMBERS (MEMBER_UNIQUE_NAME of the selected member's parent's parent)  TREE_OP 1, all children</li>
<li>MDSCHEMA_MEMBERS (MEMBER_UNIQUE_NAME of the selected member's parent) TREE_OP 8, returns itself</li>
<li>MDSCHEMA_MEMBERS (MEMBER_UNIQUE_NAME of the selected member's parent) TREE_OP 1, returns all children</li>
</ol>
<p>So, that's six requests for a level 1 member and 9 requests for a level 2 member - both of these take milliseconds to complete the whole flow, so no big deal.  When does this become a big deal?  When you do something like click the "Select multiple items" checkbox, expand a hierarchy and UNCHECK something... like if you opened the Adventure Works 2008 cube, added Delivery Date.Date as a filter, expanded the "All Periods" level and deselected the first day:<br />
<a href="http://timlaqua.com/wp-content/uploads/2010/04/DeliveryDate-Date-Setup.png"><img src="http://timlaqua.com/wp-content/uploads/2010/04/DeliveryDate-Date-Setup.png" alt="" title="DeliveryDate-Date-Setup" width="312" height="418" class="alignnone size-full wp-image-372" /></a></p>
<p>Now click OK and expand the items box - we get a familiar popup:<br />
<a href="http://timlaqua.com/wp-content/uploads/2010/04/DeliveryDate-Date-Broken.png"><img src="http://timlaqua.com/wp-content/uploads/2010/04/DeliveryDate-Date-Broken.png" alt="" title="DeliveryDate-Date-Broken" width="352" height="351" class="alignnone size-full wp-image-373" /></a></p>
<p>It comes back after a few seconds with the expected item list, but why did it take so long?  Well, based on our flows above, we have a whole bunch of level 1 members selected - 1187 of them to be exact.  That means there will be 1187 requests for their parent member (TREE_OP 4) which will all return the [All Periods] member.  To illustrate this, I traced that exact operation:<br />
<a href="http://timlaqua.com/wp-content/uploads/2010/04/DeliveryDate-Date-Profiler.png"><img src="http://timlaqua.com/wp-content/uploads/2010/04/DeliveryDate-Date-Profiler-300x144.png" alt="" title="DeliveryDate-Date-Profiler" width="300" height="144" class="alignnone size-medium wp-image-374" /></a></p>
<p>The profiler captured 1192 discover requests - 1187 of them were getting the parents of selected members, two were MDSCHEMA_CUBES requests, one was getting [All Periods], one was getting all the children of [All Periods], and one was getting the Unique Name of the root level.  Not cool.  Imagine what happens when your talking about tens of thousands of members at a particular level!  Granted, that seems unlikely but understand that the logic behind this is "I don't want to see this", "hide just this member", and so forth - in some cases people have no idea what actually happened was they unchecked one of 6,000 members.</p>
<p>So what to do about this?  Educate.  To fix the immediate problem of a seemingly broken Excel pivot table - just wait for the filter to load, it'll come back eventually.  In the future when working with Excel filters, always favor selecting vs. deselecting and filtering at higher levels in the hierarchy whenever possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://timlaqua.com/2010/04/excel-2007-hangs-when-trying-to-edit-an-olap-cube-filter/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>SSAS Cube Action: Cells Target type, URL Action type Example</title>
		<link>http://timlaqua.com/2009/03/ssas-cube-action-cells-target-type-url-action-type-example/</link>
		<comments>http://timlaqua.com/2009/03/ssas-cube-action-cells-target-type-url-action-type-example/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 03:32:02 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Scripts & Code]]></category>
		<category><![CDATA[additional actions]]></category>
		<category><![CDATA[bi]]></category>
		<category><![CDATA[business intelligence]]></category>
		<category><![CDATA[cube action]]></category>
		<category><![CDATA[excel 2007]]></category>
		<category><![CDATA[ssas]]></category>

		<guid isPermaLink="false">http://timlaqua.com/?p=165</guid>
		<description><![CDATA[Originally, we were charged with figuring out how to display SSAS cube measure descriptions via ToolTip in Excel 2007. If that's your plan, forget it - after some reading up on the interwebs, it appears that Excel doesn't even request the Description property. Additionally, if you want to add a description to Calculated Members, you [...]]]></description>
			<content:encoded><![CDATA[<p>Originally, we were charged with figuring out how to display SSAS cube measure descriptions via ToolTip in Excel 2007.  If that's your plan, forget it - after some reading up on the interwebs, it appears that Excel doesn't even request the Description property.  Additionally, if you want to add a description to Calculated Members, you have to hack it in (yuck).</p>
<p>So we went with a simple, albeit relatively crude (but effective), alternative - implementing a URL action for Cells so users can easily link out to a definition of the measure they're looking at.</p>
<p>Create a new action in your cube (Open up the cube definition, Actions tab) and configure similar to this:</p>

<div class="wp_syntax"><div class="code"><pre class="text" style="font-family:monospace;">Name: View Member Definition
&nbsp;
Action Target
    Target Type: Cells
    Target object: All cells
&nbsp;
Action Content
    Type: URL
    Action expression: &quot;http://i.domain.com/doc/Defs.aspx#&quot; 
                       + [Measures].CurrentMember.Name
&nbsp;
Additional Properties
    Invocation: Interactive
    Description: View Member Definition
    &quot;View Definition Of &quot; + [Measures].CurrentMember.Name + &quot;...&quot;
    Caption is MDX: True</pre></div></div>

<p>When you're finished, it should look something like this:<br />
<a href="http://timlaqua.com/wp-content/uploads/2009/03/ssascubecellsurlaction.png"><img src="http://timlaqua.com/wp-content/uploads/2009/03/ssascubecellsurlaction-300x243.png" alt="ssascubecellsurlaction" title="ssascubecellsurlaction" width="300" height="243" class="alignnone size-medium wp-image-166" /></a></p>
<p>For a possible way to implement the aforementioned Definitions.aspx, check out <a href="http://timlaqua.com/2009/03/scrolling-to-and-highlighting-anchor-target-via-javascript/">http://timlaqua.com/2009/03/scrolling-to-and-highlighting-anchor-target-via-javascript/</a> - which describes an early endpoint we used for this project.</p>
]]></content:encoded>
			<wfw:commentRss>http://timlaqua.com/2009/03/ssas-cube-action-cells-target-type-url-action-type-example/feed/</wfw:commentRss>
		<slash:comments>21</slash:comments>
		</item>
		<item>
		<title>How to add a calculated measure (calculated field) to an Excel 2007 PivotTable with a SSAS data source</title>
		<link>http://timlaqua.com/2008/11/how-to-add-a-calculated-measure-calculated-field-to-an-excel-2007-pivottable-with-a-ssas-data-source/</link>
		<comments>http://timlaqua.com/2008/11/how-to-add-a-calculated-measure-calculated-field-to-an-excel-2007-pivottable-with-a-ssas-data-source/#comments</comments>
		<pubDate>Wed, 05 Nov 2008 18:28:12 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[How-to Guides]]></category>
		<category><![CDATA[Scripts & Code]]></category>
		<category><![CDATA[calculated measure]]></category>
		<category><![CDATA[calculated member]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[excel 2007]]></category>
		<category><![CDATA[named set]]></category>
		<category><![CDATA[pivottable]]></category>
		<category><![CDATA[ssas]]></category>

		<guid isPermaLink="false">http://timlaqua.com/?p=50</guid>
		<description><![CDATA[As it turns out, you can do it programatically as explained by Allan Folting here: Microsoft Excel: Common Questions Around Excel 2007 OLAP PivotTables: http://blogs.msdn.com/excel/archive/2008/02/05/common-questions-around-excel-2007-OLAP-PivotTables.aspx And the parts that I have to keep looking up (I use my blog as a notebook for things I don't want to forget : Sub AddCalculatedMeasure() Dim pvt As [...]]]></description>
			<content:encoded><![CDATA[<p>As it turns out, you can do it programatically as explained by <strong>Allan Folting </strong>here:<br />
<strong>Microsoft Excel: Common Questions Around Excel 2007 OLAP PivotTables</strong>:<br />
<a href="http://blogs.msdn.com/excel/archive/2008/02/05/common-questions-around-excel-2007-OLAP-PivotTables.aspx">http://blogs.msdn.com/excel/archive/2008/02/05/common-questions-around-excel-2007-OLAP-PivotTables.aspx</a></p>
<p>And the parts that I have to keep looking up (I use my blog as a notebook for things I don't want to forget <img src='http://timlaqua.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> :</p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Sub</span> AddCalculatedMeasure() 
	<span style="color: #000080;">Dim</span> pvt <span style="color: #000080;">As</span> PivotTable
	<span style="color: #000080;">Dim</span> strName <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
	<span style="color: #000080;">Dim</span> strFormula <span style="color: #000080;">As</span> <span style="color: #000080;">String</span> 
&nbsp;
	<span style="color: #000080;">Set</span> pvt = Sheet1.PivotTables(&quot;PivotTable1&quot;)
	strName = &quot;[Measures].[Internet Sales Amount 25 %]&quot;
	strFormula = &quot;[Measures].[Internet Sales Amount]*1.25&quot;
	pvt.CalculatedMembers.Add Name:=strName, Formula:=strFormula, <span style="color: #000080;">Type</span>:=xlCalculatedMember 
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span> 
&nbsp;
<span style="color: #000080;">Sub</span> AddCalculatedMember() 
	<span style="color: #000080;">Dim</span> pvt <span style="color: #000080;">As</span> PivotTable
	<span style="color: #000080;">Dim</span> strName <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
	<span style="color: #000080;">Dim</span> strFormula <span style="color: #000080;">As</span> <span style="color: #000080;">String</span> 
&nbsp;
	<span style="color: #000080;">Set</span> pvt = Sheet1.PivotTables(&quot;PivotTable1&quot;)
	strName = &quot;[Product].[Product Categories].[Bikes].[Mountain Bikes].[Mountain-100 Silver, 38 25 %]&quot;
	strFormula = &quot;[Product].[Product Categories].[Bikes].[Mountain Bikes].[Mountain-100 Silver, 38]*1.25&quot;
	pvt.CalculatedMembers.Add Name:=strName, Formula:=strFormula, <span style="color: #000080;">Type</span>:=xlCalculatedMember
	pvt.ViewCalculatedMembers = <span style="color: #000080;">True</span> 
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span> 
&nbsp;
<span style="color: #000080;">Sub</span> AddNamedSet() 
	<span style="color: #000080;">Dim</span> pvt <span style="color: #000080;">As</span> PivotTable
	<span style="color: #000080;">Dim</span> strName <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
	<span style="color: #000080;">Dim</span> strFormula <span style="color: #000080;">As</span> <span style="color: #000080;">String</span>
	<span style="color: #000080;">Dim</span> cbf <span style="color: #000080;">As</span> CubeField 
&nbsp;
	<span style="color: #000080;">Set</span> pvt = Sheet1.PivotTables(&quot;PivotTable1&quot;)
	strName = &quot;[My Mountain Bikes]&quot;
	strFormula = &quot;[Product].[Product Categories].[Bikes].[Mountain Bikes].children&quot;
	pvt.CalculatedMembers.Add Name:=strName, Formula:=strFormula, <span style="color: #000080;">Type</span>:=xlCalculatedSet
	<span style="color: #000080;">Set</span> cbf = pvt.CubeFields.AddSet(Name:=&quot;[My Mountain Bikes]&quot;, Caption:=&quot;Mountain Bikes&quot;) 
<span style="color: #000080;">End</span> <span style="color: #000080;">Sub</span></pre></div></div>

<p>He also mentions that you can expose these members to Excel Services 2007 by creating the new objects and then removing the VBA code - very useful article.</p>
]]></content:encoded>
			<wfw:commentRss>http://timlaqua.com/2008/11/how-to-add-a-calculated-measure-calculated-field-to-an-excel-2007-pivottable-with-a-ssas-data-source/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Changing Server Names in Excel 2007 Embedded Workbook Connections</title>
		<link>http://timlaqua.com/2008/09/changing-server-names-in-excel-2007-embeded-workbook-connections/</link>
		<comments>http://timlaqua.com/2008/09/changing-server-names-in-excel-2007-embeded-workbook-connections/#comments</comments>
		<pubDate>Mon, 29 Sep 2008 19:59:44 +0000</pubDate>
		<dc:creator>Tim</dc:creator>
				<category><![CDATA[Scripts & Code]]></category>
		<category><![CDATA[connections]]></category>
		<category><![CDATA[data sources]]></category>
		<category><![CDATA[embeded connections]]></category>
		<category><![CDATA[excel]]></category>
		<category><![CDATA[excel 2007]]></category>
		<category><![CDATA[pivot table]]></category>
		<category><![CDATA[regular expressions]]></category>
		<category><![CDATA[ssas]]></category>
		<category><![CDATA[vbscript]]></category>

		<guid isPermaLink="false">http://timlaqua.com/?p=48</guid>
		<description><![CDATA[Ok, so you want to migrate servers, eh? Well - all your business users pry have a couple thousand Pivot Reports lying around that point to the old server. We need to point all references to the old server at the new server. There are two places these references exist (afaik) - The My Data [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, so you want to migrate servers, eh?  Well - all your business users pry have a couple thousand Pivot Reports lying around that point to the old server.  We need to point all references to the old server at the new server.</p>
<p>There are two places these references exist (afaik) - The My Data Sources folder (Windows XP / Excel 2007) which holds all of the odc objects for the logged in user, and the real pain - Embedded data sources in Excel Workbooks.</p>
<p>For the odc objects - you can just loop through the My Data Sources folder files and do a little find/replace action.</p>
<p>For the Excel files - we need to first find all the files, then loop through them and hunt for embedded Connections.  Once we find a connection, we can just blindly replace occurrences of the old server name with the new server name.  The first thing we need here is a function we can call recursively to go hunt down all the excel files - then we loop through and play with the connections (when found).<br />
<span id="more-48"></span></p>
<p>Let me know how it goes!  Here's the full version:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
</pre></td><td class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #000080;">Set</span> regEx = <span style="color: #000080;">New</span> RegExp
regEx.IgnoreCase = <span style="color: #000080;">True</span>
regEx.Global = <span style="color: #000080;">True</span>
<span style="color: #000080;">Set</span> WshShell = Wscript.CreateObject(&quot;Wscript.Shell&quot;)
strMyDocsPath = WshShell.RegRead(&quot;HKCU\Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders\Personal&quot;)
strDataSourceDir = strMyDocsPath &amp; &quot;\My Data Sources&quot;
&nbsp;
<span style="color: #008000;">'======================== Fix all the Data Sources
</span><span style="color: #000080;">Set</span> objFSO = CreateObject(&quot;Scripting.FileSystemObject&quot;)
<span style="color: #000080;">Set</span> Folder = objFSO.GetFolder(strDataSourceDir)
<span style="color: #000080;">Set</span> Files = Folder.Files
&nbsp;
<span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> File <span style="color: #000080;">In</span> Files
	<span style="color: #000080;">If</span> LCase(Right(File.Name, 4)) = &quot;.odc&quot; <span style="color: #000080;">Then</span>
	    <span style="color: #000080;">Set</span> objReadFile = objFSO.OpenTextFile(File.Path, 1)
	    strContents = &quot;&quot;
&nbsp;
		<span style="color: #000080;">Do</span> <span style="color: #000080;">While</span> <span style="color: #000080;">Not</span> objReadFile.AtEndOfStream
			strContents = strContents &amp; objReadFile.ReadLine &amp; vbCrLf
		<span style="color: #000080;">Loop</span>
&nbsp;
	    objReadFile.<span style="color: #000080;">Close</span>
&nbsp;
		regEx.Pattern = &quot;(?=.*Data Source=OldCrappyServerName.*)(&lt;odc:ConnectionString&gt;.+&lt;/odc:ConnectionString&gt;)&quot;
&nbsp;
		<span style="color: #000080;">If</span> regEx.Test(strContents) <span style="color: #000080;">Then</span>
			<span style="color: #000080;">Set</span> colMatches = regEx.Execute(strContents)
&nbsp;
			<span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> objMatch <span style="color: #000080;">in</span> colMatches
				strOldConnectionString = objMatch.SubMatches(0)
				regEx.Pattern = &quot;Data Source=OldCrappyServerName&quot;
				strNewConnectionString = regEx.Replace(strOldConnectionString, &quot;Data Source=NewAwesomeServerName&quot;)
				regEx.Pattern = strOldConnectionString
				strContents = regEx.Replace(strContents, strNewConnectionString)
			<span style="color: #000080;">Next</span>
&nbsp;
			<span style="color: #000080;">Set</span> objWriteFile = objFSO.CreateTextFile(File.Path, <span style="color: #000080;">True</span>)
			objWriteFile.Write strContents
			objWriteFile.<span style="color: #000080;">Close</span>
		<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
	<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
<span style="color: #000080;">Next</span>
&nbsp;
&nbsp;
<span style="color: #008000;">'================================ Fix all the embeded connections (yikes)
</span>
<span style="color: #000080;">Set</span> arrFileList = CreateObject( &quot;System.Collections.ArrayList&quot; )
<span style="color: #000080;">Set</span> objExcel = CreateObject(&quot;Excel.Application&quot;)
objExcel.DisplayAlerts = <span style="color: #000080;">False</span>
&nbsp;
populateExcelFileList(strMyDocsPath)
&nbsp;
<span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> strFileName <span style="color: #000080;">In</span> arrFileList
	objExcel.Workbooks.<span style="color: #000080;">Open</span>(strFileName)
	<span style="color: #000080;">Set</span> objWorkbook = objExcel.Workbooks(1)
	<span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> objWorkbook <span style="color: #000080;">in</span> objExcel.Workbooks
		<span style="color: #000080;">If</span> objWorkbook.Connections.Count &gt; 0 <span style="color: #000080;">Then</span>
			WScript.Echo strFileName
			<span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> objConnection <span style="color: #000080;">in</span> objWorkbook.Connections
				strOldConnection =  objConnection.OLEDBConnection.Connection
				regEx.Pattern = &quot;OldCrappyServerName&quot;
				strNewConnection = regEx.Replace(strOldConnection, &quot;NewAwesomeServerName&quot;)
				objConnection.OLEDBConnection.Connection = strNewConnection
			<span style="color: #000080;">Next</span>
&nbsp;
		<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
&nbsp;
		objWorkbook.<span style="color: #000080;">Close</span> <span style="color: #000080;">True</span>
	<span style="color: #000080;">Next</span>
&nbsp;
	objExcel.Quit
<span style="color: #000080;">Next</span>
&nbsp;
<span style="color: #000080;">Function</span> populateExcelFileList(path)
	<span style="color: #000080;">Set</span> pathFolder = objFSO.GetFolder(path)
	<span style="color: #000080;">Set</span> pathFiles = pathFolder.Files
	<span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> pathSubFolder <span style="color: #000080;">in</span> pathFolder.SubFolders
		populateExcelFileList(pathSubFolder.Path)
	<span style="color: #000080;">Next</span>
&nbsp;
	<span style="color: #000080;">For</span> <span style="color: #000080;">Each</span> pathFile <span style="color: #000080;">in</span> pathFiles
		<span style="color: #000080;">If</span> (LCase(Right(pathFile.Name, 5)) = &quot;.xlsx&quot; _
			<span style="color: #000080;">Or</span> LCase(Right(pathFile.Name, 4)) = &quot;.xls&quot;) _
			<span style="color: #000080;">And</span> Left(pathFile.Name, 1) &lt;&gt; &quot;~&quot; <span style="color: #000080;">Then</span>
			arrFileList.Add pathFile.Path
		<span style="color: #000080;">End</span> <span style="color: #000080;">If</span>
	<span style="color: #000080;">Next</span>
<span style="color: #000080;">End</span> <span style="color: #000080;">Function</span></pre></td></tr></table></div>

<p><strong><em>Update</em></strong><br />
I added in support for .xls files - doing this against .xls files can (and usually will) break backwards compatibility for SSAS Pivot Tables.</p>
]]></content:encoded>
			<wfw:commentRss>http://timlaqua.com/2008/09/changing-server-names-in-excel-2007-embeded-workbook-connections/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

