<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	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/"
		>
<channel>
	<title>Comments on: Save a global variable in an Excel workbook</title>
	<atom:link href="http://dailydoseofexcel.com/archives/2011/08/14/save-a-global-variable-in-an-excel-workbook/feed/" rel="self" type="application/rss+xml" />
	<link>http://dailydoseofexcel.com/archives/2011/08/14/save-a-global-variable-in-an-excel-workbook/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Wed, 22 May 2013 22:14:49 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Rob van Gelder</title>
		<link>http://dailydoseofexcel.com/archives/2011/08/14/save-a-global-variable-in-an-excel-workbook/#comment-70369</link>
		<dc:creator>Rob van Gelder</dc:creator>
		<pubDate>Wed, 07 Dec 2011 09:03:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=5238#comment-70369</guid>
		<description><![CDATA[That&#039;s a way better idea. I don&#039;t remember reading that article. Good work!]]></description>
		<content:encoded><![CDATA[<p>That&#8217;s a way better idea. I don&#8217;t remember reading that article. Good work!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tushar Mehta</title>
		<link>http://dailydoseofexcel.com/archives/2011/08/14/save-a-global-variable-in-an-excel-workbook/#comment-70334</link>
		<dc:creator>Tushar Mehta</dc:creator>
		<pubDate>Tue, 06 Dec 2011 10:47:04 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=5238#comment-70334</guid>
		<description><![CDATA[Rob: Why not save the pointer to the collection in another project (workbook) a la http://www.dailydoseofexcel.com/archives/2011/11/01/protect-a-global-variable-in-another-vb-project/

You will need to save only the pointer to the collection, i.e., the collection variable.]]></description>
		<content:encoded><![CDATA[<p>Rob: Why not save the pointer to the collection in another project (workbook) a la <a href="http://www.dailydoseofexcel.com/archives/2011/11/01/protect-a-global-variable-in-another-vb-project/" rel="nofollow">http://www.dailydoseofexcel.com/archives/2011/11/01/protect-a-global-variable-in-another-vb-project/</a></p>
<p>You will need to save only the pointer to the collection, i.e., the collection variable.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob van Gelder</title>
		<link>http://dailydoseofexcel.com/archives/2011/08/14/save-a-global-variable-in-an-excel-workbook/#comment-70288</link>
		<dc:creator>Rob van Gelder</dc:creator>
		<pubDate>Mon, 05 Dec 2011 08:50:58 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=5238#comment-70288</guid>
		<description><![CDATA[As I understand it, each object contains a reference count - a count of how many other things are referencing the object.
So long as the collection reference count is not zero, I&#039;d hope that items within the collection are be safe.

I developed the experiment and Excel crashed pretty quickly. Either I&#039;m not creating the loop properly or the theory is flawed.
Never mind!]]></description>
		<content:encoded><![CDATA[<p>As I understand it, each object contains a reference count &#8211; a count of how many other things are referencing the object.<br />
So long as the collection reference count is not zero, I&#8217;d hope that items within the collection are be safe.</p>
<p>I developed the experiment and Excel crashed pretty quickly. Either I&#8217;m not creating the loop properly or the theory is flawed.<br />
Never mind!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fzz</title>
		<link>http://dailydoseofexcel.com/archives/2011/08/14/save-a-global-variable-in-an-excel-workbook/#comment-70279</link>
		<dc:creator>fzz</dc:creator>
		<pubDate>Mon, 05 Dec 2011 05:46:07 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=5238#comment-70279</guid>
		<description><![CDATA[@Rob, if the members of the collection were identified by pointers, could those pointers change due to garbage collection upon state reset? That is, could the locations in memory of objects within a collection change upon state reset and garbage collection? If so, saving such collections would be problematic.]]></description>
		<content:encoded><![CDATA[<p>@Rob, if the members of the collection were identified by pointers, could those pointers change due to garbage collection upon state reset? That is, could the locations in memory of objects within a collection change upon state reset and garbage collection? If so, saving such collections would be problematic.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob van Gelder</title>
		<link>http://dailydoseofexcel.com/archives/2011/08/14/save-a-global-variable-in-an-excel-workbook/#comment-70275</link>
		<dc:creator>Rob van Gelder</dc:creator>
		<pubDate>Sun, 04 Dec 2011 23:07:11 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=5238#comment-70275</guid>
		<description><![CDATA[Hi Tushar

I have an idea I&#039;d like to fly by you (or anyone else listening).

I have filled a VBA collection object with items and I&#039;d like this collection object retained, even if VBA loses its state. This is much the same problem as you have with ribbons.
It wouldn&#039;t be enough to store a pointer address in an Excel cell because VBA garbage collection might have cleaned up.
Then I thought of the experiences with creating a Parent property against child classes - memory leaks could occur.

Here&#039;s the sneaky idea.
What if I could purposely create a reference loop (memory leak) so VBA skips that object for garbage collection, then save the pointer address out to an Excel cell?
My object is then always available, even after loss of state, and I can keep my collection of items alive for whenever I need them.

Thoughts?]]></description>
		<content:encoded><![CDATA[<p>Hi Tushar</p>
<p>I have an idea I&#8217;d like to fly by you (or anyone else listening).</p>
<p>I have filled a VBA collection object with items and I&#8217;d like this collection object retained, even if VBA loses its state. This is much the same problem as you have with ribbons.<br />
It wouldn&#8217;t be enough to store a pointer address in an Excel cell because VBA garbage collection might have cleaned up.<br />
Then I thought of the experiences with creating a Parent property against child classes &#8211; memory leaks could occur.</p>
<p>Here&#8217;s the sneaky idea.<br />
What if I could purposely create a reference loop (memory leak) so VBA skips that object for garbage collection, then save the pointer address out to an Excel cell?<br />
My object is then always available, even after loss of state, and I can keep my collection of items alive for whenever I need them.</p>
<p>Thoughts?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jan Karel Pieterse</title>
		<link>http://dailydoseofexcel.com/archives/2011/08/14/save-a-global-variable-in-an-excel-workbook/#comment-65913</link>
		<dc:creator>Jan Karel Pieterse</dc:creator>
		<pubDate>Tue, 30 Aug 2011 16:08:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=5238#comment-65913</guid>
		<description><![CDATA[&lt;p&gt;Well, I&#039;ve been using the trick to re-instate the ribbon object for a cuople of weeks now and it seems to work all the time, so sounds like my luck is unsurpassed :-)&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>Well, I&#8217;ve been using the trick to re-instate the ribbon object for a cuople of weeks now and it seems to work all the time, so sounds like my luck is unsurpassed <img src='http://dailydoseofexcel.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tushar Mehta</title>
		<link>http://dailydoseofexcel.com/archives/2011/08/14/save-a-global-variable-in-an-excel-workbook/#comment-65901</link>
		<dc:creator>Tushar Mehta</dc:creator>
		<pubDate>Tue, 30 Aug 2011 05:40:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=5238#comment-65901</guid>
		<description><![CDATA[&lt;p&gt;Hi Jan Karel,&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;Here&#039;s the scenario where I would not trust this technique.&lt;/p&gt;
&lt;p&gt;There&#039;s a class, say, Class1.  There&#039;s a global object X of type Class1.&lt;/p&gt;
&lt;p&gt;So, there is only 1 handle (pointer) to the pointer that points to the memory allocated to X.&lt;/p&gt;
&lt;p&gt;The code saves the value of the handle in X in a worksheet cell (or a name).&lt;/p&gt;
&lt;p&gt;The project suffers a loss of state and X is lost.&lt;/p&gt;
&lt;p&gt;At this point, there is no handle to the pointer to the memory location of X.  Since there are zero handles pointing to the pointer to X, X is now subject to garbage collection.&lt;/p&gt;
&lt;p&gt;The code re-establishes the handle to X using the technique in this discussion.  But, now, there is no guarantee that X is still hanging around in memory!  I&#039;d say that if this technique works it&#039;s sheer luck.&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>Hi Jan Karel,</p>
<p>Thanks.</p>
<p>Here&#8217;s the scenario where I would not trust this technique.</p>
<p>There&#8217;s a class, say, Class1.  There&#8217;s a global object X of type Class1.</p>
<p>So, there is only 1 handle (pointer) to the pointer that points to the memory allocated to X.</p>
<p>The code saves the value of the handle in X in a worksheet cell (or a name).</p>
<p>The project suffers a loss of state and X is lost.</p>
<p>At this point, there is no handle to the pointer to the memory location of X.  Since there are zero handles pointing to the pointer to X, X is now subject to garbage collection.</p>
<p>The code re-establishes the handle to X using the technique in this discussion.  But, now, there is no guarantee that X is still hanging around in memory!  I&#8217;d say that if this technique works it&#8217;s sheer luck.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jan Karel Pieterse</title>
		<link>http://dailydoseofexcel.com/archives/2011/08/14/save-a-global-variable-in-an-excel-workbook/#comment-65884</link>
		<dc:creator>Jan Karel Pieterse</dc:creator>
		<pubDate>Mon, 29 Aug 2011 12:55:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=5238#comment-65884</guid>
		<description><![CDATA[&lt;p&gt;Hi Tushar,&lt;/p&gt;
&lt;p&gt;Clear description of how to use this technique!&lt;/p&gt;
&lt;p&gt;One question. You write: &quot;A key limitation with this technique is that the object variable of interest must be declared outside of the VB project of the workbook containing this code.&quot;. This is contradictory to my experience: the technique works just fine for me, with the object variable being in just one VBProject (the one that may get &quot;zapped&quot;).&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>Hi Tushar,</p>
<p>Clear description of how to use this technique!</p>
<p>One question. You write: &#8220;A key limitation with this technique is that the object variable of interest must be declared outside of the VB project of the workbook containing this code.&#8221;. This is contradictory to my experience: the technique works just fine for me, with the object variable being in just one VBProject (the one that may get &#8220;zapped&#8221;).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sam</title>
		<link>http://dailydoseofexcel.com/archives/2011/08/14/save-a-global-variable-in-an-excel-workbook/#comment-65605</link>
		<dc:creator>sam</dc:creator>
		<pubDate>Tue, 16 Aug 2011 16:39:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=5238#comment-65605</guid>
		<description><![CDATA[&lt;p&gt;You could also use the Hidden Name space which is Global to the Current Instance of Excel&lt;/p&gt;
&lt;p&gt;To create&lt;br&gt;
Application.ExecuteExcel4Macro &quot;SET.NAME(&quot;&quot;RibbonState&quot;&quot;,&quot;&quot;1234567890?&quot;)&quot;&lt;/p&gt;
&lt;p&gt;To retrieve&lt;br&gt;
rState = Application.ExecuteExcel4Macro(&quot;RibbonState&quot;)&lt;/p&gt;
&lt;p&gt;To Delete&lt;br&gt;
Application.ExecuteExcel4Macro &quot;SET.NAME(&quot;&quot;RibbonState&quot;&quot;)&quot;&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>You could also use the Hidden Name space which is Global to the Current Instance of Excel</p>
<p>To create<br />
Application.ExecuteExcel4Macro &#8220;SET.NAME(&#8220;&#8221;RibbonState&#8221;",&#8221;"1234567890?&#8221;)&#8221;</p>
<p>To retrieve<br />
rState = Application.ExecuteExcel4Macro(&#8220;RibbonState&#8221;)</p>
<p>To Delete<br />
Application.ExecuteExcel4Macro &#8220;SET.NAME(&#8220;&#8221;RibbonState&#8221;")&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tushar Mehta</title>
		<link>http://dailydoseofexcel.com/archives/2011/08/14/save-a-global-variable-in-an-excel-workbook/#comment-65583</link>
		<dc:creator>Tushar Mehta</dc:creator>
		<pubDate>Mon, 15 Aug 2011 18:43:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=5238#comment-65583</guid>
		<description><![CDATA[&lt;p&gt;That&#039;s an interesting idea and there are other places to save information: another add-in, a text file, and the Windows registry being some of them.&lt;/p&gt;
]]></description>
		<content:encoded><![CDATA[<p>That&#8217;s an interesting idea and there are other places to save information: another add-in, a text file, and the Windows registry being some of them.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
