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

  • Thread starter Thread starter Vijay
  • Start date Start date
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
 
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"
 
Back
Top