Macro
(1)
WordApp
(1)
ApplicationClass
(1)
ECreateFileName
(1)
String
(1)
FileName
(1)
Object
(1)
PREVENTION
(1)

vs.net and Word 3000

Asked By Do
10-Dec-06 10:02 AM
Hello
I am trying to run a macro in word from vs.net.

My Code is:
Dim WordApp As New Word.ApplicationClass()
Dim ECreateFileName As String
Dim FileName As Object = "C:\NEW LOSS PREVENTION\CreateEmal\" +
ECreateFileName
Dim isVisible As Object = True
Dim missing As Object = System.Reflection.Missing.Value
WordApp.Visible = True
Dim aDoc As Word.Document = WordApp.Documents.Open(FileName, missing,
missing, missing, missing, missing, missing, missing, missing, isVisible)

I get the following errors;

'C:\NEW LOSS PREVENTION\Form4.vb(4504) : error BC30002: Type
'Word.ApplicationClass' is not defined.
'C:\NEW LOSS PREVENTION\Form4.vb(4515) : error BC30002: Type
'Word.Document' is not defined.

Can anyone help.

--
Don Mylrea

Hi,Make sure you have added a "project reference" to the Word application if

Asked By Gerry Hickman
10-Dec-06 05:31 PM
Hi,

Make sure you have added a "project reference" to the Word application
if you have not already done so, otherwise the COM Interop might not work.



--
Gerry Hickman (London UK)

Thanks for the reply.

Asked By Do
10-Dec-06 08:24 PM
Thanks for the reply.
I am kind of new at this, How do I add a  "project reference" to the Word
Application.

I have two programs doing the same thing, one works and the other does not???

Special thanks for Help.
--
Don Mylrea

Hi,If you have a working app, just that that.

Asked By Gerry Hickman
11-Dec-06 01:13 PM
Hi,

If you have a working app, just that that.

If you want to add a project reference, you should be able to do this in
Solution Explorer by right clicking the project, and then choosing "Add
Reference", then the "COM" tab and then choose the Word Object Library.
Once the reference is added, you can use Object Browser to see it's
objects such as the Application object.



--
Gerry Hickman (London UK)
Hi Gerry I thank you very much, that was exactly what I needed.
Asked By Do
12-Dec-06 12:35 AM
Hi Gerry
I thank you very much, that was exactly what I needed.

The Program runs the word macro well.

Many Thanks
--
Don Mylrea
Post Question To EggHeadCafe