Group:  General ยป microsoft.public.officedev
Thread: Creating a new Word document using ASP.NET (VB.NET)

DotNetBag
.NET Development Newsgroups

HTVi
TV Discussion Newsgroups

Our Hot Pick: Rising Antivirus 2006 - Certified by TUV & Checkmark! Get 10% discount by entering this coupon code: ONDISCOUNT10
Rising Antivirus 2006

Creating a new Word document using ASP.NET (VB.NET)
"goof1972" <bfung25[ at ]hotmail.com> 14.12.2005 21:36:51
Hello All,

I have a VB.NET web application (1.1 framework) that creates a new Word
document through interop.word.dll. I have a Windows Server 2003 with
Office XP Professional installed. I've also installed the Office XP
PIA.

In my VB.NET application, I want to create a new Word document using
the following code:

Dim MSWord As New Word.ApplicationClass
Dim doc As Word.Document

doc = MSWord.Documents.Add()

Unfortunately, when I step through the code, I discover that once the
previous code bit was done, doc=Nothing. I was expecting doc to be a
Word.document object. There was no errors..nothing! I even checked the
Event Logs and could not find any error messages! Why is this
happening? It looks like a new Word document is not being created!

Any help would be appreciated.

Thanks in advance!

Brian

Re: Creating a new Word document using ASP.NET (VB.NET)
Cindy M -WordMVP- <C.Meister-C[ at ]hispeed.ch> 20.12.2005 09:59:00
Hi Goof1972,

[Quoted Text]
> n my VB.NET application, I want to create a new Word document using
> the following code:
>
> Dim MSWord As New Word.ApplicationClass
> Dim doc As Word.Document
>
> doc = MSWord.Documents.Add()
>
> Unfortunately, when I step through the code, I discover that once the
> previous code bit was done, doc=Nothing.
>
Try this and see if it works any better:

Dim MSWord as Word.Application
Dim doc as Word.Document

MSWord = New Word.Application
doc = MSWord.Documents.Add()

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question
or reply in the newsgroup and not by e-mail :-)

Home | Search | Terms | Imprint | Contact
Newsgroups Reader - provided by WiredBox.Net