ASP.NET(vb.net) & Word (Word Application) - Page Setup - This article example scripts you will learn how to Create Word Document and Setup the page using ASP.NET Scripts
ShotDev Focus:
- ASP.NET(vb.net) & Word (Word Application) - Page Setup
Example
AspNetWordPageSetup.aspx
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="AspNetWordPageSetup.aspx.vb" Inherits="AspNetWordPageSetup" %> <html> <head runat="server"> <title>ShotDev.Com Tutorial</title> </head> <body> <form id="form1" runat="server"> <asp:Label ID="lblText" runat="server"></asp:Label> </form> </body> </html>
AspNetWordPageSetup.aspx.vb
Imports Microsoft.Office.Interop.Word
Public Class AspNetWordPageSetup
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim Wrd As New Microsoft.Office.Interop.Word.Application
Dim DocName As String = "MyDoc/MyWord.doc"
Wrd.Application.Visible = False
Wrd.Documents.Add()
With Wrd
.Selection.PageSetup.LeftMargin = "0.25"
.Selection.PageSetup.RightMargin = "0.25"
.Selection.PageSetup.TopMargin = "0.25"
.Selection.PageSetup.BottomMargin = "0.25"
.Selection.TypeText("Welcome To www.ShotDev.Com")
End With
Wrd.ActiveDocument.SaveAs(Server.MapPath(DocName))
Wrd.Application.Quit()
Wrd = Nothing
End Sub
End Class
Screenshot

