web 2.0

ASP.NET(vb.net) & Word (Word.Application) - Page Breaking

ASP.NET(vb.net) & Word (Word Application) - Page Breaking - This article example scripts you will learn how to set Page Breaking in Word document using ASP.NET Scripts

ShotDev Focus:
- ASP.NET(vb.net) & Word (Word Application) - Page Breaking

Example

AspNetWordPageBreaking.aspx

  1. <%@ Page Language="VB" AutoEventWireup="false" CodeFile="AspNetWordParagraphsRange.aspx.vb" Inherits="AspNetWordParagraphsRange" %>  
  2. <html>  
  3. <head runat="server">  
  4. <title>ShotDev.Com Tutorial</title>  
  5. </head>  
  6. <body>  
  7. <form id="form1" runat="server">  
  8. <asp:Label ID="lblText" runat="server"></asp:Label>  
  9. </form>  
  10. </body>  
  11. </html>  

AspNetWordPageBreaking.aspx.vb

  1. Imports Microsoft.Office.Interop.Word  
  2. Public Class AspNetWordParagraphsRange  
  3. Inherits System.Web.UI.Page  
  4.   
  5. Protected Sub Page_Load(ByVal sender As ObjectByVal e As System.EventArgs) Handles Me.Load  
  6.   
  7. Const wdColorDarkRed = &H80  
  8. Const wdAlignParagraphCenter = 1  
  9. Const wdAlignParagraphLeft = 0  
  10. Const wdParagraph = 4  
  11. Const wdHorizontalPositionMargin = 0  
  12. Const wdTableLeft = -999998  
  13. Const wdCollapseEnd = 0  
  14.   
  15. Dim Wrd As New Microsoft.Office.Interop.Word.Application  
  16. Dim WrdDoc As Microsoft.Office.Interop.Word.Document  
  17. Dim MyRange1, MyRange2, MyRange3 As Microsoft.Office.Interop.Word.Range  
  18. Dim DocName As String = "MyDoc/MyWord.doc"  
  19.   
  20. Wrd.Application.Visible = False  
  21.   
  22. WrdDoc = Wrd.Documents.Add()  
  23.   
  24. MyRange1 = WrdDoc.Paragraphs.Add.Range  
  25. With MyRange1  
  26. .ParagraphFormat.Alignment = wdAlignParagraphCenter  
  27. .Font.Name = "Verdana"  
  28. .Font.Size = "30"  
  29. .Font.Bold = True  
  30. .InsertBefore("www.ShotDev.Com" & vbCrLf & "Version 2010")  
  31. End With  
  32.   
  33. MyRange2 = WrdDoc.Paragraphs.Add.Range  
  34. With MyRange2  
  35. .ParagraphFormat.Alignment = wdAlignParagraphCenter  
  36. .Font.Name = "Verdana"  
  37. .Font.Size = "15"  
  38. .Font.Bold = True  
  39. .InsertBefore(vbCrLf & vbCrLf & "PHP,ASP and ASP.NET Tutorial")  
  40. End With  
  41.   
  42. MyRange3 = WrdDoc.Paragraphs.Add.Range  
  43. With MyRange3  
  44. .ParagraphFormat.Alignment = wdAlignParagraphCenter  
  45. .Font.Name = "Verdana"  
  46. .Font.Size = "10"  
  47. .Font.Bold = True  
  48. .Font.Color = wdColorDarkRed  
  49. .Underline = True  
  50. .InsertBefore(vbCrLf & vbCrLf & vbCrLf & vbCrLf & "All Rights Reserved")  
  51. End With  
  52.   
  53. WrdDoc.SaveAs(Server.MapPath(DocName))  
  54. Wrd.Application.Quit()  
  55. Wrd = Nothing  
  56.   
  57. End Sub  
  58. End Class  

Screenshot

ASP.NET(vb.net) & Word (Word Application) - Page Breaking

ASP.NET(vb.net) & Word (Word Application) - Page Breaking
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.