web 2.0

How to use ASP & Word (Word.Application) - Page Breaking

How to use ASP & Word (Word.Application) - Page Breaking This is learn/tutorial asp developers how to using ASP script Create Word document and add Page Breaking

ShotDev Focus:
- ASP & Create Word document and add Page Breaking

Example

asp_word_paragraphs.asp


<% OptionĀ  Explicit %>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<%
Const wdAlignParagraphCenter = 1
Const wdAlignParagraphLeft = 0
Const wdParagraph = 4
Const wdHorizontalPositionMargin = 0
Const wdTableLeft = -999998
Const wdCollapseEnd = 0

Dim Wrd,WrdDoc,DocName
Dim MyRange1,MyRange2
Set Wrd = CreateObject("Word.Application")
DocName = "MyDoc/MyWord.doc"
Wrd.Application.Visible = False

Set WrdDoc = Wrd.Documents.Add()

Set MyRange1 = WrdDoc.Paragraphs.Add.Range
With MyRange1
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Font.Name = "Verdana"
.Font.Size = "30"
.Font.Bold = True
.InsertBefore("www.ShotDev.Com"&vbCrLf&"Version 2010")
.Font.Bold = True
End With

Set MyRange1 = WrdDoc.Paragraphs.Add.Range
With MyRange1
.InsertBefore(Chr(12)) '*** New Page ***'
End With

Set MyRange2 = WrdDoc.Paragraphs.Add.Range
With MyRange2
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Font.Name = "Verdana"
.Font.Size = "15"
.Font.Bold = True
.InsertBefore("PHP,ASP and ASP.NET Tutorial")
End With

WrdDoc.SaveAs(Server.MapPath(DocName))
Wrd.Application.Quit
Set Wrd = Nothing
%>

Word Created <a href="<%=DocName%>">Click here</a> to Download.
</body>
</html>

Create a asp file and save to path root-path/myasp/

Run
http://localhost/myasp/asp_word_page.asp

Screenshot

ASP & Create Word document and add Page Breaking.

ASP & Create Word document and add Page Breaking.
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.