<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: Because ActiveDocument.Text() Would Be Too Easy...</title>
	<link>http://ask.metafilter.com/103284/Because-ActiveDocumentText-Would-Be-Too-Easy/</link>
	<description>Comments on Ask MetaFilter post Because ActiveDocument.Text() Would Be Too Easy...</description>
	<pubDate>Thu, 02 Oct 2008 17:35:37 -0800</pubDate>
	<lastBuildDate>Thu, 02 Oct 2008 17:35:37 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: Because ActiveDocument.Text() Would Be Too Easy...</title>
		<link>http://ask.metafilter.com/103284/Because-ActiveDocumentText-Would-Be-Too-Easy</link>	
		<description>I&apos;m writing a code analysis tool in VB.NET for Visual Studio 2005.  Help me extract the text of the active window. &lt;br /&gt;&lt;br /&gt; My plan: Create an add-in that will put an &quot;Analyze&quot; item in the Tools menu.  The developer opens her code file, clicks the menu item, and all of the text in the currently-active window is passed to the analysis engine I am writing.&lt;br&gt;
&lt;br&gt;
What I can&apos;t seem to crack is how to get all of the text in the active window.  Googling has provided some insight as to how to get TextPoint and EditPoint objects, but nothing that takes me all the way to just having a string (or some reasonable object) that contains a bunch of text for me to process.&lt;br&gt;
&lt;br&gt;
Is this even possible?  If not, I&apos;d be happy for suggestions as to how I can divine the full path to the disk file that contains the text in the active window.  Many thanks.</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2008:site.103284</guid>
		<pubDate>Thu, 02 Oct 2008 17:31:31 -0800</pubDate>
		<dc:creator>DWRoelands</dc:creator>
		
			<category>visualstudio2005</category>
		
			<category>vbnet</category>
		
			<category>extensibility</category>
		
	</item> <item>
		<title>By: sanko</title>
		<link>http://ask.metafilter.com/103284/Because-ActiveDocumentText-Would-Be-Too-Easy#1496349</link>	
		<description>Check out &lt;a href=&quot;http://www.codingthewheel.com&quot;&gt;this guy&apos;s&lt;/a&gt; series on writing a pokerbot.  Probably more than you need to know about reading text from windows, and a bunch of other cool stuff too.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.103284-1496349</guid>
		<pubDate>Thu, 02 Oct 2008 17:35:37 -0800</pubDate>
		<dc:creator>sanko</dc:creator>
	</item><item>
		<title>By: mmascolino</title>
		<link>http://ask.metafilter.com/103284/Because-ActiveDocumentText-Would-Be-Too-Easy#1496398</link>	
		<description>Rather than writing a standalone analysis program, have you considered writing a Visual Studio plugin that expose explicit APIs that do what you want (among a whole host of other things).  There are also &lt;a href=&quot;http://www.devexpress.com/Downloads/Visual_Studio_Add-in/DXCore/&quot;&gt;frameworks&lt;/a&gt; for making plugin writing easier than what Microsoft provides.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.103284-1496398</guid>
		<pubDate>Thu, 02 Oct 2008 18:43:23 -0800</pubDate>
		<dc:creator>mmascolino</dc:creator>
	</item><item>
		<title>By: jedicus</title>
		<link>http://ask.metafilter.com/103284/Because-ActiveDocumentText-Would-Be-Too-Easy#1496542</link>	
		<description>More specifically, you&apos;ll want to look at the &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/xc52cke4(VS.80).aspx&quot;&gt;Automation and Extensibility APIs for VS&lt;/a&gt;.  The &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/envdte(VS.80).aspx&quot;&gt;EnvDTE&lt;/a&gt; and &lt;a href=&quot;http://msdn.microsoft.com/en-us/library/0e105c68(VS.80).aspx&quot;&gt;EnvDTE80&lt;/a&gt; namespaces will be particularly important.&lt;br&gt;
&lt;br&gt;
&lt;code&gt;Sub PathExample()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim doc As Document&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim docPath As String&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;doc = DTE.ActiveDocument&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;docPath = doc.Path&lt;br&gt;
End Sub&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
would get you the path to the current document.&lt;br&gt;
&lt;br&gt;
This is the easiest (ha!) way I can come up with to get the text of a document.&lt;br&gt;
&lt;code&gt;&lt;br&gt;
Sub TextExample()&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim doc as TextDocument&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim ep As EditPoint&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;Dim docText as String&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;doc = DTE.ActiveDocument.Object(&quot;TextDocument&quot;)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;ep = doc.StartPoint.CreateEditPoint&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;docText = ep.GetText(doc.EndPoint.CreateEditPoint)&lt;br&gt;
&lt;br&gt;
End Sub&lt;/code&gt;&lt;br&gt;
&lt;br&gt;
Sorry for any VB.Net errors.  I normally code in C#, so I&apos;m not as familiar with VB syntax.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.103284-1496542</guid>
		<pubDate>Thu, 02 Oct 2008 22:22:56 -0800</pubDate>
		<dc:creator>jedicus</dc:creator>
	</item>
	</channel>
</rss>
