Click here to Skip to main content
15,893,668 members
Home / Discussions / C#
   

C#

 
GeneralRe: QQ group for Wuhan-China's programer Pin
whChina20-Jun-06 23:27
whChina20-Jun-06 23:27 
QuestionMultiplatform (32bits/64bits/CE) & Interop Pin
Super Lloyd19-Jun-06 16:16
Super Lloyd19-Jun-06 16:16 
AnswerRe: Multiplatform (32bits/64bits/CE) & Interop Pin
leppie19-Jun-06 22:01
leppie19-Jun-06 22:01 
GeneralRe: Multiplatform (32bits/64bits/CE) & Interop Pin
Super Lloyd19-Jun-06 22:13
Super Lloyd19-Jun-06 22:13 
GeneralRe: Multiplatform (32bits/64bits/CE) & Interop Pin
Super Lloyd19-Jun-06 22:17
Super Lloyd19-Jun-06 22:17 
GeneralRe: Multiplatform (32bits/64bits/CE) & Interop Pin
Super Lloyd20-Jun-06 5:40
Super Lloyd20-Jun-06 5:40 
QuestionXSL:, XMLDOM C# Pin
Ramon Gzz M19-Jun-06 16:10
Ramon Gzz M19-Jun-06 16:10 
QuestionMicrosoft Word/Excel Automation Errors [modified] Pin
dbloch19-Jun-06 15:19
dbloch19-Jun-06 15:19 
Hi All

I have a question relating to the resources/namespaces required when automating either to Excel or Word as I find that namespaces and resources that work perfectly on my machine with Office 2003, do not work with other machines who have Office 2003.

I'm having to type the full Microsoft.Office.Interop.Word/Excel namespace out which in the tutorials and other sample code I've seen, is not the case so I wonder if there is something wrong with my installation.

Here is a little program I created which takes all Word Documents within a directory and merges them into one large Word Document.
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
using System.IO;<br />
using Microsoft.Office;<br />
<br />
 object oMissing = System.Reflection.Missing.Value;<br />
<br />
        public Form1()<br />
        {<br />
            InitializeComponent();<br />
<br />
<br />
        }<br />
<br />
        private void Form1_Load(object sender, EventArgs e)<br />
        {<br />
            lblSelect.Visible = false;<br />
<br />
        }<br />
<br />
<br />
        private void btnOK_Click(object sender, EventArgs e)<br />
        {<br />
            Microsoft.Office.Interop.Word._Document oDoc;<br />
            Microsoft.Office.Interop.Word._Document cDoc;<br />
            Microsoft.Office.Interop.Word.Application wordAppA = new Microsoft.Office.Interop.Word.Application();<br />
            Microsoft.Office.Interop.Word.Application wordAppB = new Microsoft.Office.Interop.Word.Application();<br />
            oDoc = wordAppA.Documents.Add(ref oMissing, ref oMissing, ref oMissing, ref oMissing);<br />
<br />
            folderBrowserDialog1.ShowDialog();<br />
            DirectoryInfo di = new DirectoryInfo(folderBrowserDialog1.SelectedPath.ToString());<br />
            FileInfo[] diFiles = di.GetFiles("*.doc");<br />
<br />
            lblSelect.Text = "Folder currently selected: " + folderBrowserDialog1.SelectedPath.ToString();<br />
            lblSelect.Visible = true;<br />
            <br />
            int count = 0;<br />
            foreach(FileInfo fi in diFiles)<br />
            {<br />
                count++;<br />
            }<br />
<br />
            progressBar1.Maximum = count;<br />
<br />
            count = 0;<br />
            foreach (FileInfo fi in diFiles)<br />
            {<br />
                object file = fi.FullName;<br />
                cDoc = wordAppB.Documents.Open(ref file, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing, ref oMissing);<br />
                cDoc.Select();<br />
                wordAppB.Selection.Copy();<br />
                oDoc.Application.Selection.Paste();<br />
                oDoc.Application.Selection.InsertBreak(ref oMissing);<br />
                cDoc.Close(ref oMissing, ref oMissing, ref oMissing);<br />
                count++;<br />
                progressBar1.Value = count;<br />
            }<br />
            wordAppB.Quit(ref oMissing, ref oMissing, ref oMissing);<br />
            wordAppA.Visible = true;<br />
            Form1.ActiveForm.Close();<br />
        }<br />


Now this works absolutely perfectly on my machine without any fail what so ever but when I try to put it on any other machine even though we both have Office 2003, I get this following error

************** Exception Text **************
System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Office.Interop.Word, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.Office.Interop.Word, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'

I can get around this by having it copy the Microsoft.Office.Interop.Word.dll into the source directory of my application and it will then work but this is a pain because I shouldn't need to do it.

Anyone got any ideas?

Thanks so much

David Bloch
Houston Medical


-- modified at 21:19 Monday 19th June, 2006
QuestionUser settings for application Pin
Mike0919-Jun-06 14:27
Mike0919-Jun-06 14:27 
AnswerRe: User settings for application Pin
Mike Poz19-Jun-06 15:03
Mike Poz19-Jun-06 15:03 
QuestionHow to get distinct items from an array? Pin
mejobloggs19-Jun-06 13:34
mejobloggs19-Jun-06 13:34 
AnswerRe: How to get distinct items from an array? Pin
Alexander Wiseman19-Jun-06 14:04
Alexander Wiseman19-Jun-06 14:04 
GeneralRe: How to get distinct items from an array? Pin
mejobloggs19-Jun-06 15:57
mejobloggs19-Jun-06 15:57 
GeneralRe: How to get distinct items from an array? Pin
leppie19-Jun-06 22:07
leppie19-Jun-06 22:07 
GeneralRe: How to get distinct items from an array? Pin
Alexander Wiseman20-Jun-06 5:43
Alexander Wiseman20-Jun-06 5:43 
AnswerRe: How to get distinct items from an array? Pin
Leslie Sanford19-Jun-06 16:43
Leslie Sanford19-Jun-06 16:43 
GeneralRe: How to get distinct items from an array? Pin
mejobloggs19-Jun-06 17:09
mejobloggs19-Jun-06 17:09 
AnswerRe: How to get distinct items from an array? Pin
Judah Gabriel Himango19-Jun-06 18:22
sponsorJudah Gabriel Himango19-Jun-06 18:22 
QuestionProcess.Start() mailto exception - default mail client Pin
stretchtack19-Jun-06 13:11
stretchtack19-Jun-06 13:11 
AnswerRe: Process.Start() mailto exception - default mail client Pin
Alexander Wiseman19-Jun-06 13:54
Alexander Wiseman19-Jun-06 13:54 
GeneralRe: Process.Start() mailto exception - default mail client Pin
stretchtack19-Jun-06 19:20
stretchtack19-Jun-06 19:20 
GeneralSTAThread vs. MTAThread - Process.Start() Pin
stretchtack20-Jun-06 7:28
stretchtack20-Jun-06 7:28 
GeneralRe: STAThread vs. MTAThread - Process.Start() Pin
Alexander Wiseman20-Jun-06 8:46
Alexander Wiseman20-Jun-06 8:46 
QuestionSession State Transfer Pin
Expert Coming19-Jun-06 11:39
Expert Coming19-Jun-06 11:39 
QuestionNeural networks in c# Pin
yasar khan19-Jun-06 10:46
yasar khan19-Jun-06 10:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.