I am a very newbie on Aspose.Word, I just start my project which is require the wording stamp on word doc. Could anyone post the example script here, so that i can start with sample and make it faster…
My requirement is: I have a word doc template, and need to stamp/write the wording to that document, and then send to customer by email.
Send email with attachment is fine for me, but when I attemp the example “Letter.aspx”, I tried to change the parameter name, but word document has incorrect result, it only have <> inside the document…
Thank you very much.
I tried the script as below:
Public Class Letter
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Protected WithEvents fullNameEdit As System.Web.UI.WebControls.TextBox
Protected WithEvents generateBtn As System.Web.UI.WebControls.Button
Protected WithEvents companyEdit As System.Web.UI.WebControls.TextBox
Protected WithEvents cityEdit As System.Web.UI.WebControls.TextBox
Protected WithEvents address2Edit As System.Web.UI.WebControls.TextBox
Protected WithEvents addressEdit As System.Web.UI.WebControls.TextBox
Protected WithEvents Label4 As System.Web.UI.WebControls.Label
Protected WithEvents Label2 As System.Web.UI.WebControls.Label
Protected WithEvents Label1 As System.Web.UI.WebControls.Label
Protected WithEvents Label3 As System.Web.UI.WebControls.Label
Protected WithEvents Label5 As System.Web.UI.WebControls.Label
Protected WithEvents saveTypeBtn As System.Web.UI.WebControls.RadioButtonList
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here
'Open the uploaded document.
Dim word As Word = New Word
Dim doc As Document = word.Open(MapPath(".") + “…\Documents\abc.doc”)
'Create a document builder object for the document (concept similar to StringBuilder in .NET)
Dim builder As DocumentBuilder = New DocumentBuilder(doc)
'The “cursor” is already position at the beginning of the document, but you can
'move it using several DocumentBuilder.MoveToXXX methods.
'Use DocumentBuilder.Font and many other properties to specify formatting.
builder.Font.Size = 14
builder.Font.Name = “Arial”
'Use DocumentBuilder.Writeln, Write, or InsertXXX methods to insert content.
'Save the file
but get the error as below:
Exception Details: System.Exception: …\Documents\abc.doc already exists
Help Please . Thank you.
If you want just to insert some text into any document, then it’s probably best to use DocumentBuilder exactly as you have already done.
I’d suggest you specify full path for saving the document. When you run as an ASP.NET application who knows where it tries to save it.
It is very strange that you save the document as “stan.doc” but you get error “abc.doc” already exists. Is this exactly what you getting?