web 2.0

How to use ASP & Word (Word.Application) - Font & Style

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

ShotDev Focus:
- ASP & Create Word document and add Font & Style

Example

asp_word_style.asp

  1. <% Option  Explicit %>  
  2. <html>  
  3. <head>  
  4. <title>ShotDev.Com Tutorial</title>  
  5. </head>  
  6. <body>  
  7. <%  
  8. Dim Wrd,DocName  
  9. Set Wrd = CreateObject("Word.Application")  
  10. Wrd.Application.Visible = False  
  11. Wrd.Documents.Add()  
  12. DocName = "MyDoc/MyWord.doc"  
  13. With Wrd  
  14. .Selection.Font.Name = "Verdana"  
  15. .Selection.Font.Size = "25"  
  16. .Selection.Font.Bold = True  
  17. .Selection.Font.Italic = True  
  18. .Selection.TypeText "Welcome To www.ShotDev.Com"  
  19. End With  
  20.   
  21. Wrd.ActiveDocument.BuiltInDocumentProperties("Title").Value = "Doc  Title"  
  22. Wrd.ActiveDocument.BuiltInDocumentProperties("Subject").Value = "Doc  Subject"  
  23. Wrd.ActiveDocument.BuiltInDocumentProperties("Author").Value = "Doc  Author"  
  24. Wrd.ActiveDocument.BuiltInDocumentProperties("Manager").Value = "Doc  Manager"  
  25. Wrd.ActiveDocument.BuiltInDocumentProperties("Company").Value = "Doc  Company"  
  26. Wrd.ActiveDocument.BuiltInDocumentProperties("Category").Value = "Doc  Category"  
  27. Wrd.ActiveDocument.BuiltInDocumentProperties("Application Name").Value =  "Doc Application Name"  
  28. Wrd.ActiveDocument.BuiltInDocumentProperties("Keywords").Value = "Doc  Keywords"  
  29. Wrd.ActiveDocument.BuiltInDocumentProperties("Comments").Value = "Doc  Comments"  
  30.   
  31. Wrd.ActiveDocument.SaveAs(Server.MapPath(DocName))  
  32. Wrd.Application.Quit  
  33. Set Wrd = Nothing  
  34. %>  
  35. Word Created <a href="<%=DocName%>">Click here</a> to  Download.  
  36. </body>  
  37. </html>  

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

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

Screenshot

ASP & Create Word document and add Font & Style.
.
.
.
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.