5
Answers

C#NET2008 Window Application using Microsoft WORD 2003

Lennie Kuah

Lennie Kuah

13y
2.3k
1
Hullo Good Friends,
I do need your help. Please help me.

I am encountering a very puzzling problems using Microsoft Office WORD 2003 on C#NET2008 Window Application.
I am trying to export Customer Invoice Transactions to NonTemplate WORD 2003 Document and it's not working



using System;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office;
using Microsoft.Office.Interop.Word;

Error messages generated:
Error 1 The type name 'Application' does not exist in the type 'Microsoft.Office.Interop.Word.Words'

Error 2 The type name 'Document' does not exist in the type 'Microsoft.Office.Interop.Word.Words'

Error 3 The type name 'Table' does not exist in the type 'Microsoft.Office.Interop.Word.Words'

Error 4 The type name 'Range' does not exist in the type 'Microsoft.Office.Interop.Word.Words'

Error 5 The type or namespace name 'Word' could not be found (are you missing a using directive or an assembly reference?)


namespace CSharpNet2008UseWORD2003
{
public partial class FrmWORDReport : Form
{
//---declare and instantiate WORD Objects
private Words.Application objWord;
private Words.Document objDoc;
private Words.Table objTable;
private Words.Range objTableRange;
}
}

I have tried using these coding and it's not working either:
private Word.Application objWord;
private Word.Document objDoc;
private Word.Table objTable;
private Word.Range objTableRange;

Answers (5)
0
Vulpes
NA 98.3k 1.5m 13y
I'm not sure what you mean by the 'reference file used' as that's just something I happen to know from my own efforts using Word or Excel interop.

However, I found a Microsoft Support link here which confirms the 'using directive' point (paragraph 7) and also contains some sample code which you may find useful:
0
Lennie Kuah
NA 27 0 13y
Hullo Vulpes,
Thank you very much for sharing information with me. Appreciate your help very much.


I will try our your suggested coding and will return to you with the result.
Can you please share with me the REFERENCE FILE USED ?


If my application is working, I will post the Overall coding here to share with other Newbies who have similar problems.


cheers,
Lennie
0
Vulpes
NA 98.3k 1.5m 13y
I'd replace this 'using' directive:
  
   using Microsoft.Office.Interop.Word;

with this one:

   using Word = Microsoft.Office.Interop.Word;

Code like this should then work (note that it's 'Word' not 'Words'):

   private Word.Application objWord;
   private Word.Document objDoc;
   private Word.Table objTable;
   private Word.Range objTableRange; 

0
Lennie Kuah
NA 27 0 13y

Hi Suthish,
I have tried your suggestion when I develop the application and it generate this error message. that's the reason why I posted my problem earlier. Thanks anyway for trying to help me.

This is the earlier Posting:
Error messages generated:
Error 1 The type name 'Application' does not exist in the type 'Microsoft.Office.Interop.Word.Words'
0
Suthish Nair
NA 31.7k 4.6m 13y
try.. Words.Application objWord = new Words.Application();