web 2.0

ASP.NET(vb.net) & Word (Word.Application) - Font and Style

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

ShotDev Focus:
- ASP.NET(vb.net) & Word (Word Application) - Font and Style

Example

AspNetWordFontStyle.aspx

<%@ Page Language="VB" AutoEventWireup="false" CodeFile="AspNetWordFontStyle.aspx.vb" Inherits="AspNetWordFontStyle" %>
<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>

AspNetWordFontStyle.aspx.vb


Imports Microsoft.Office.Interop.Word
Public Class AspNetWordFontStyle
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"

Const wdColorDarkBlue = &H800000

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"
'*** Font Properties ***'
.Selection.Font.Name = "Verdana"
.Selection.Font.Size = "25"
.Selection.Font.Bold = True
.Selection.Font.Italic = True
.Selection.Font.Color = wdColorDarkBlue
'.Selection.Font.Emboss = True
'.Selection.Font.Engrave = True
'.Selection.Font.Kerning = True
'.Selection.Font.Shadow = True
'.Selection.Font.StrikeThrough = True
'.Selection.Font.Subscript = True
'.Selection.Font.Superscript = True
.Selection.TypeText("Welcome To www.ShotDev.Com")
End With

Wrd.ActiveDocument.SaveAs(Server.MapPath(DocName))
Wrd.Application.Quit()
Wrd = Nothing

'*** Font Color ***'
'Const wdColorAqua = &HCCCC33
'Const wdColorAutomatic = &HFF000000
'Const wdColorBlack = &H0
'Const wdColorBlue = &HFF0000
'Const wdColorBlueGray = &H996666
'Const wdColorBrightGreen = &HFF00
'Const wdColorBrown = &H3399
'Const wdColorDarkBlue = &H800000
'Const wdColorDarkGreen = &H3300
'Const wdColorDarkRed = &H80
'Const wdColorDarkTeal = &H663300
'Const wdColorDarkYellow = &H8080
'Const wdColorGold = &HCCFF
'Const wdColorGray05 = &HF3F3F3
'Const wdColorGray10 = &HE6E6E6
'Const wdColorGray125 = &HE0E0E0
'Const wdColorGray15 = &HD9D9D9
'Const wdColorGray20 = &HCCCCCC
'Const wdColorGray25 = &HC0C0C0
'Const wdColorGray30 = &HB3B3B3
'Const wdColorGray35 = &HA6A6A6
'Const wdColorGray375 = &HA0A0A0
'Const wdColorGray40 = &H999999
'Const wdColorGray45 = &H8C8C8C
'Const wdColorGray50 = &H808080
'Const wdColorGray55 = &H737373
'Const wdColorGray60 = &H666666
'Const wdColorGray625 = &H606060
'Const wdColorGray65 = &H595959
'Const wdColorGray70 = &H4C4C4C
'Const wdColorGray75 = &H404040
'Const wdColorGray80 = &H333333
'Const wdColorGray85 = &H262626
'Const wdColorGray875 = &H202020
'Const wdColorGray90 = &H191919
'Const wdColorGray95 = &HC0C0C
'Const wdColorGreen = &H8000
'Const wdColorIndigo = &H993333
'Const wdColorLavender = &HFF99CC
'Const wdColorLightBlue = &HFF6633
'Const wdColorLightGreen = &HCCFFCC
'Const wdColorLightOrange = &H99FF
'Const wdColorLightTurquoise = &HFFFFCC
'Const wdColorLightYellow = &H99FFFF
'Const wdColorLime = &HCC99
'Const wdColorOliveGreen = &H3333
'Const wdColorOrange = &H66FF
'Const wdColorPaleBlue = &HFFCC99
'Const wdColorPink = &HFF00FF
'Const wdColorPlum = &H663399
'Const wdColorRed = &HFF
'Const wdColorRose = &HCC99FF
'Const wdColorSeaGreen = &H669933
'Const wdColorSkyBlue = &HFFCC00
'Const wdColorTan = &H99CCFF
'Const wdColorTeal = &H808000
'Const wdColorTurquoise = &HFFFF00
'Const wdColorViolet = &H800080
'Const wdColorWhite = &HFFFFFF
'Const wdColorYellow = &HFFFF
End Sub
End Class

Screenshot

ASP.NET(vb.net) & Word (Word Application) - Font and Style

.
.
.
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.