473,386 Members | 1,715 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Word automation that work in an .exe and not in a .dll

DJ
Hi,
I have this piece of code that work well in an .exe. If I move this
code to a function in a dll and have an .exe calling the function, an
exception is raised : The server threw an exception. Why the same code
is not working in my dll??? The error occurs with the first call to
the InsertFile function (and yes the files that I insert exists). In
fact any call to Doc.Words.First is throwing an exception.
Dim App As Word.Application
Dim oMissing As Object = Missing.Value
Dim PageBreak As Object = Word.WdBreakType.wdPageBreak
Dim visible As Object = False

Try
App = New Word.Application
App.Visible = False

Dim Doc As _Document = App.Documents.Add(oMissing,
oMissing, oMissing, visible)

For Each FName As String In FNameArray
Doc.Words.First.InsertFile(FName)
Doc.Words.First.InsertBreak(PageBreak)
Next
Catch ex As Exception
Resultat = False
Finally
Dim saveChanges As Object = True
Dim originalFormat As Object = Missing.Value
Dim routeDocument As Object = Missing.Value

App.Quit(saveChanges, originalFormat, routeDocument)
End Try
Thank you!
Nov 20 '05 #1
0 1043

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Tom Dauria | last post by:
What I am trying to do is write a resume into a word document from information in an Access database. I have been using bookmarks and inserting table results into the document and so far it's...
12
by: Cheval | last post by:
Has anyone had any problems with inter-office automation between MS Word and MS Access in Office 2003? I have recently installed office 2003 in a new folder and have left the older office 2000...
6
by: Colleyville Alan | last post by:
I have an application that has an Access table that stores the locations of slides in a Powerpoint file. This used to work fine when there were about 4 files and 200 slides. The database would...
4
by: Daniel | last post by:
Hello, i have a problem with the word automation from c#. First, i want to mention, that i don't have any dependencies from word in my c#-project, i want to use the system.reflection model to...
0
by: mharris | last post by:
I need help with merging two Word documents into one through C# code. The problem isn't so much getting the documents put into one as it is maintaining the appropriate formatting, or rather...
4
by: Yohancef Chin | last post by:
Hi, Being fairly new to .NET I am looking for a way to call MS Word from an event on a webform, and after the user is finished save that created document to an SQL Server database. Has anyone...
3
by: Yohancef Chin | last post by:
Hi, Being fairly new to .NET I am looking for a way to call MS Word from an event on a webform, and after the user is finished save that created document to an SQL Server database. Has anyone...
4
by: Rob | last post by:
Here is my issue: I am trying to load word through vb.net code behind an ASP.NET webform. I know it is possible to use the Automation and COM classes because a co-worker has it working on his...
22
by: liya.tansky | last post by:
Hello, I'm developing an intranet (win XP, .NET 2, Visual Studio 2005, Microsoft.Office.Interop.Word.dll in references) and needed to implement find-replace in word doc before sending letter and...
10
by: cj2 | last post by:
I open a word template in VB and add values to the bookmarks then save the document as as pdf. When I then go to close the document it pops up a save as dialog box. It's already saved the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.