ASP to Word

Results 1 to 2 of 2

Thread: ASP to Word

  1. #1
    Join Date
    Dec 1969

    Default ASP to Word

    From a webpage, I need to send a set of database records to a word document and protect that document from user changes. I also need to have page breaks between each record.<BR><BR>I&#039;ve got asp code that creates the word document, but is there a way I can add page breaks and also lock down the word doc? <BR><BR>The other challenge is to lock down all text in the word doc except for one place where a user can enter their name.

  2. #2
    Join Date
    Dec 1969

    Default RE: ASP to Word

    The easiest way to figure out Word VBA is to create a Macro and then edit it. It will come up in VBA which gives you the basic syntax for doing the same thing in ASP, with some slight modifications(creation of objects and the such). Anyway to insert a pagebreak you can use:<BR><BR>Selection.InsertBreak Type:=wdPageBreak<BR><BR>Selection happens to be a child object of the Application Object which is probably created in your ASP like:<BR>dim word<BR>set word = server.createobject("Word.Application")<BR><BR>The n to insert the page break:<BR><BR>word.Selection.InsertBreak 7<BR><BR>If your wondering where the 7 came from go into the object browser in the VBA editor and look at wdbreaktype and that will give you the constants.<BR><BR>As for the protection the VBA code is:<BR><BR> ActiveDocument.Protect Password:="password", NoReset:=False, Type:= _<BR> wdAllowOnlyRevisions<BR><BR>and the ASP would look like(I used password as my password)<BR><BR>word.ctiveDocument.Protect "password", false, 0<BR><BR>I got 0 in the same way as above object browser wdprotectiontype<BR><BR>I hope this helps, and remember for Office products Macro is your friend. PS This should only be used for low volume websites and if you are using IIS 4.0 you will have to allow outofprocess components. Also make sure to Quit at the end of your script otherwise you will keep an instance of word hanging around.<BR><BR>Matt

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts