Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Where does the dll go? 1

Status
Not open for further replies.

Trusts

Programmer
Feb 23, 2005
268
US
Hi,

I created a VB.Net app using VS2003. The purpose is to enter some text into the app form and then create a Word document with the text going in the document.

In developing this, I referenced the Word 11 library on my computer. And also in the code behind have
Imports Microsoft.Office.Interop

Here is part of the code - the function accepts two pieces of text and a path, and creates the doc and puts the text in it:

Dim wApp As New Word.Application
Dim cDoc As New Word.Document
Dim wrd As Word.Application

Try
wrd = New Word.Application
Catch ex As Exception
Return ex.Message
End Try

' Create a new document & range
Dim doc As Word.Document = wrd.Documents.Add()
Dim rng As Word.Range = doc.Range()

Dim para1 As Word.Paragraph
Dim para2 As Word.Paragraph
para1 = doc.Paragraphs.Add
para1.Range.Text = text1
para1.Range.InsertParagraphAfter()

para2 = doc.Paragraphs.Add
para2.Range.Text = text2
para2.Range.InsertParagraphAfter()
doc.Activate()

The word doc is then saved, etc.

This works fine for me.

In the Bin folder is the exe and also Interop.Microsoft.Office.Core.dll

I sent these two files to a friend and told him to put them in the same directory and run the app. He has the CLR because the app runs, but when he clicks the button that runs the code to create the Doc, he gets an error:

"handling error, can not find the dll or one of its components"

So my question is what needs to be done. Does the dll have to be registered? Should it be in some other folder - like the System32 folder?

Thanks,
KB

 
Does your friend have the same version of Word as you do?
If not, your code wont work unless you adopt late binding.

If he has the same version, try making an install set rather than just sending the exe and dll.


Sweep
...if it works, you know the rest..
Always remember that Google is your friend

curse.gif
 
SqueakinSweep -

Thanks. I am waiting to hear back from my friend about what Word version he has.

In the meantime can you explain how I would code it different to have late-binding?

Thanks,
KB
 
<late-binding?

Change
Code:
        Dim wApp As New Word.Application
        Dim cDoc As New Word.Document
        Dim wrd As Word.Application

to

Code:
        Dim wApp As Object
        Dim cDoc As Object
        Dim wrd As Object
        wApp = New Word.Application
        cDoc = New Word.Document
The difference then is that you are specifying what type of Object you have at run time rather than at compile time. Hence late binding.

HTH

Bob

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top