01.
Imports
Microsoft.Office.Interop.PowerPoint
02.
Public
Class
AspNetPowerPointOpenPPT
03.
Inherits
System.Web.UI.Page
04.
05.
Protected
Sub
Page_Load(
ByVal
sender
As
Object
,
ByVal
e
As
System.EventArgs)
Handles
Me
.Load
06.
07.
Const
wdColorLightGreen = &HCCFFCC
08.
Const
wdColorBlue = &HCCFFCC
09.
10.
Dim
ppApp
As
New
Microsoft.Office.Interop.PowerPoint.Application
11.
Dim
ppPres
As
Presentation
12.
Dim
ppSlide1, ppSlide2, ppSlide3, ppSlide4
As
Slide
13.
Dim
ppName
As
String
=
"MyPP/MyPPt.ppt"
14.
Dim
ppDoc
As
String
=
"thaicreate.ppt"
15.
16.
ppApp.Visible =
True
17.
18.
ppPres = ppApp.Presentations.Open(Server.MapPath(ppDoc))
19.
20.
ppSlide1 = ppPres.Slides(1)
21.
22.
ppSlide1.Shapes.AddTextbox(1, 50, 100, 700, 100)
23.
ppSlide1.Shapes(1).TextFrame.TextRange.Text =
"I Love ThaiCreate.Com 1"
24.
ppSlide1.Shapes(1).TextFrame.TextRange.Font.Name =
"Arial"
25.
ppSlide1.Shapes(1).TextFrame.TextRange.Font.Size = 10
26.
ppSlide1.Shapes(1).TextFrame.TextRange.Font.Color.RGB = wdColorLightGreen
27.
28.
ppSlide1.Shapes.AddTextbox(1, 50, 150, 700, 100)
29.
ppSlide1.Shapes(2).TextFrame.TextRange.Text =
"I Love ThaiCreate.Com 2"
30.
ppSlide1.Shapes(2).TextFrame.TextRange.Font.Name =
"Arial"
31.
ppSlide1.Shapes(2).TextFrame.TextRange.Font.Size = 20
32.
33.
ppSlide1.Shapes.AddTextbox(1, 50, 200, 700, 100)
34.
ppSlide1.Shapes(3).TextFrame.TextRange.Text =
"I Love ThaiCreate.Com 3"
35.
ppSlide1.Shapes(3).TextFrame.TextRange.Font.Name =
"Arial"
36.
ppSlide1.Shapes(3).TextFrame.TextRange.Font.Size = 30
37.
38.
ppSlide1.Shapes.AddTextbox(1, 50, 250, 700, 100)
39.
ppSlide1.Shapes(4).TextFrame.TextRange.Text =
"I Love ThaiCreate.Com 4"
40.
ppSlide1.Shapes(4).TextFrame.TextRange.Font.Name =
"Arial"
41.
ppSlide1.Shapes(4).TextFrame.TextRange.Font.Size = 40
42.
43.
ppSlide1.Shapes.AddTextbox(1, 50, 300, 700, 100)
44.
ppSlide1.Shapes(5).TextFrame.TextRange.Text =
"I Love ThaiCreate.Com 5"
45.
ppSlide1.Shapes(5).TextFrame.TextRange.Font.Name =
"Arial"
46.
ppSlide1.Shapes(5).TextFrame.TextRange.Font.Size = 50
47.
ppSlide1.Shapes(5).TextFrame.TextRange.Font.Color.RGB = wdColorBlue
48.
ppSlide1.Shapes.AddPicture(Server.MapPath(
"thaicreate-2009.gif"
), 0, 1, 310, 380, 100, 100)
49.
50.
51.
ppSlide2 = ppPres.Slides.Add(2, 3)
52.
ppSlide2.Shapes(1).TextFrame.TextRange.Text =
"www.ThaiCreate.Com Version"
53.
ppSlide2.Shapes(1).TextFrame.TextRange.Font.Color.RGB = wdColorBlue
54.
ppSlide2.Shapes(2).TextFrame.TextRange.Text =
"Version 2008"
& vbCr & _
55.
"Version 2008"
& vbCr &
"Version 2008"
& vbCr &
"Version 2008"
56.
ppSlide2.Shapes(3).TextFrame.TextRange.Text =
"Version 2009"
& vbCr & _
57.
"Version 2009"
& vbCr &
"Version 2009"
& vbCr &
"Version 2009"
58.
59.
ppSlide3 = ppPres.Slides.Add(3, 4)
60.
ppSlide3.Shapes(1).TextFrame.TextRange.Text =
"We Love ThaiCreate.Com"
61.
ppSlide3.Shapes(1).TextFrame.TextRange.Font.Color.RGB = wdColorBlue
62.
63.
ppSlide4 = ppPres.Slides.Add(4, 5)
64.
ppSlide4.Shapes(1).TextFrame.TextRange.Text =
"We Love ThaiCreate.Com"
65.
ppSlide4.Shapes(1).TextFrame.TextRange.Font.Color.RGB = wdColorBlue
66.
ppSlide4.Shapes(2).TextFrame.TextRange.Text =
"2005"
& vbCr &
"2006"
& vbCr &
"2007"
& vbCr &
"2008"
& vbCr &
"2009"
67.
68.
ppApp.Presentations(1).SaveAs(Server.MapPath(ppName))
69.
ppApp.Quit()
70.
ppApp =
Nothing
71.
72.
Me
.lblText.Text =
"PowerPoint Created <a href="
& ppName &
">Click here</a> to Download."
73.
74.
End
Sub
75.
End
Class