Problem with writing ms-word hheader through ASP.NET(VB.NET)

V

Vijay

Hi,

I have to generate a word or rtf file on the fly whould
have a Header and footer both but i m not able to include
the header and footer in the document can anyone suggest
me how can i do that.
Currrently i am having a template of word document which
has a header ad footer and in that i m having tags which i
m replacing with my data.But when i m genrating the
document its not including the header and footer in the
document.How can i do that.
Any suggestion or example given willl be highly
appreicated.

thaanks
vijay
 
J

Jurjen de Groot

Vijay,

I've done this using bookmarks, the code below is written using VB6 but the
references to the Ms-Word object should work in dotnet as well !!

Hope this helps

Jurjen de Groot,
G.I.T.S. Netherlands.


Dim objWord as Object
Set objWord = new Word.Application

// set seekview to PageHeader
objWord.ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader

// Find your bookmarks in the header/footer here and insert text accordingly
objWord.ActiveDocument.Bookmarks("HeaderClientName").Select
objWord.Selection.TypeText Text:="ClientName"

// set seekview to Main Document
objWord.ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

// Find your bookmarks in the main document and insert text accordingly
objWord.ActiveDocument.Bookmarks("MainClientName").Select
objWord.Selection.TypeText Text:="ClientName"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top