Msword

  • Thread starter Thread starter krishna murthy
  • Start date Start date
K

krishna murthy

Hi,
I have a doubt.
I have to open a predefined templet using VB.NET whenever
i apply a button click and at the same time i have to add
some data to the predefined templet using VB.NET i.e
handling the The word document through VB.NET code.
plz help me.


Regards,
krishna.
 
Krishna,

Please keep in the original thread, in this way answering you give the ones
who answer more work, because they don't know what was already answered.

Cor
 
Hi Krishna,

You can go through the following code snippet to see if it helps you

Public Function StartWord() As Word.Application
Dim wrdTmp As Word.Application
On Error Resume Next

Set wrdTmp = GetObject(, "Word.Application")
If Err.Number <> 0 Then
'Using New here would work just the
'same as using CreateObject, but I wanted
'it to be parallel for the other function.
Set wrdTmp = CreateObject("Word.Application")
End If
Set StartWord = wrdTmp
End Function

To use the function, write code like this (after you've set a reference to
Word in your application) in your button click event:

Dim wrdApp As Word.Application
Set wrdApp = StartWord()

HTH

Mona
 
Back
Top