General discussion

Locked

Here... Where the tech hits my brain....

By mkyes ·
Tags: Off Topic
blog root

This conversation is currently closed to new comments.

1 total post (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Challenge of the day

by mkyes In reply to Here... Where the tech hi ...

<p>It's been a while since I wrote code.. it this challenge takes me to places I havent seen as of yet. it take me officially into VS 2005 and takes deeply back to Office 2003 to get some fields out and put them in a database. the code for this given all the Sp's etc I've put on is not too bad but here is a swag that shows you how to open a word document from .NET:</p><font size="2">
<font color="#808080" size="2">///</font><font color="#808080" size="2"><summary></p></font><font size="2">
<font color="#808080" size="2">///</font><font color="#008000" size="2"> Loads the Document specified by the documentName parameter</p></font><font size="2">
<font color="#808080" size="2">///</font><font color="#808080" size="2"></summary></p></font><font size="2">
<font color="#808080" size="2">///</font><font color="#808080" size="2"><param name="documentName"></param></p></font><font size="2">
<font color="#0000ff" size="2">public</font><font color="#0000ff" size="2">void</font><font size="2"> OpenWordDocuments(</font><font color="#0000ff" size="2">string</font><font size="2"> documentName)</p>
<p>{</p>
<font color="#0000ff" size="2">object</font><font size="2"> fileName = documentName;</p>
<font color="#0000ff" size="2">object</font><font size="2"> isVisible = </font><font color="#0000ff" size="2">true</font><font size="2">;</p>
<font color="#0000ff" size="2">object</font><font size="2"> missing = System.Reflection.</font><font color="#008080" size="2">Missing</font><font size="2">.Value;</p>
<font color="#0000ff" size="2">object</font><font size="2"> readOnly = </font><font color="#0000ff" size="2">true</font><font size="2">;</p>
<font color="#0000ff" size="2">object</font><font size="2"> confirmConversions = </font><font color="#0000ff" size="2">false</font><font size="2">;</p>
<font color="#0000ff" size="2">object</font><font size="2"> addToRecentFiles = </font><font color="#0000ff" size="2">false</font><font size="2">;</p>
<font color="#0000ff" size="2">object</font><font size="2"> revert = </font><font color="#0000ff" size="2">false</font><font size="2">;</p>
<font color="#0000ff" size="2">object</font><font size="2"> wdOpenFormatAuto = Microsoft.Office.Interop.Word.</font><font color="#008080" size="2">WdOpenFormat</font><font size="2">.wdOpenFormatAuto;</p>


<p>wordApp.Visible = </font><font color="#0000ff" size="2">true</font><font size="2">;</p>
<font color="#0000ff" size="2">try</p></font><font size="2">
<p>{</p>
<p>Microsoft.Office.Interop.Word.</font><font color="#008080" size="2">Document</font><font size="2"> aDoc = wordApp.Documents.Open(</font><font color="#0000ff" size="2">ref</font><font size="2"> fileName,</p>
<font color="#0000ff" size="2">ref</font><font size="2"> confirmConversions, </font><font color="#0000ff" size="2">ref</font><font size="2"> readOnly, </font><font color="#0000ff" size="2">ref</font><font size="2"> addToRecentFiles, </font><font color="#0000ff" size="2">ref</font><font size="2"> missing, </font><font color="#0000ff" size="2">ref</font><font size="2"> missing,</p>
<font color="#0000ff" size="2">ref</font><font size="2"> revert, </font><font color="#0000ff" size="2">ref</font><font size="2"> missing,</p>
<font color="#0000ff" size="2">ref</font><font size="2"> missing, </font><font color="#0000ff" size="2">ref</font><font size="2"> wdOpenFormatAuto, </font><font color="#0000ff" size="2">ref</font><font size="2"> missing, </font><font color="#0000ff" size="2">ref</font><font size="2"> isVisible, </font><font color="#0000ff" size="2">ref</font><font size="2"> missing, </font><font color="#0000ff" size="2">ref</font><font size="2"> missing,</p>
<font color="#0000ff" size="2">ref</font><font size="2"> missing, </font><font color="#0000ff" size="2">ref</font><font size="2"> missing);</p>
<p>}</p>
<font color="#0000ff" size="2">catch</font><font size="2"> (System.</font><font color="#008080" size="2">Exception</font><font size="2"> e)</p>
<p>{</p>
<font color="#008080" size="2">Console</font><font size="2">.Out.WriteLine(</font><font color="#800000" size="2">"E:="</font><font size="2">+e);</p>
<p>}</p>
<p>}</p></font>

Back to After Hours Forum
1 total post (Page 1 of 1)  

Related Discussions

Related Forums