用VBA在WORD中繪制圖形及函數(shù)圖象(共3頁)_第1頁
用VBA在WORD中繪制圖形及函數(shù)圖象(共3頁)_第2頁
用VBA在WORD中繪制圖形及函數(shù)圖象(共3頁)_第3頁
全文預(yù)覽已結(jié)束

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡介

1、精選優(yōu)質(zhì)文檔-傾情為你奉上用VBA在WORD中繪制圖形及函數(shù)圖象Sub Macro1()用VBA在WORD中繪制圖形及函數(shù)圖象1.繪制一個(gè)“開關(guān)”圖形'宏 Switch實(shí)現(xiàn)在指定位置繪制一個(gè)“開關(guān)”圖形。Sub Switch() ActiveDocument.Shapes.AddLine(100, 110, 120, 110).Name = "shp1" ActiveDocument.Shapes.AddShape(msoShapeOval, 120, 108, 4, 4).Name = "shp2" 'Oval 橢圓形 ActiveDo

2、cument.Shapes.AddShape(msoShapeOval, 130, 108, 4, 4).Name = "shp3" ActiveDocument.Shapes.AddLine(134, 110, 154, 110).Name = "shp4" ActiveDocument.Shapes.AddLine(122, 108, 132, 104).Name = "shp5" ActiveDocument.Shapes.Range(Array("shp1", "shp2", "

3、;shp3", "shp4", "shp5").GroupEnd Sub2.添加繪圖畫布'下列示例在新文檔中添加繪圖畫布,然后在繪圖畫布上添加兩個(gè)圖形,并設(shè)置填充和線條屬性。Sub AddInlineCanvas() Dim docNew As Document Dim shpCanvas As Shape Set docNew = Documents.Add 'Add a drawing canvas to the new document Set shpCanvas = docNew.Shapes.AddCanvas( _

4、Left:=150, Top:=150, Width:=70, Height:=70) shpCanvas.WrapFormat.Type = wdWrapInline 'Add shapes to drawing canvas With shpCanvas.CanvasItems .AddShape msoShapeHeart, Left:=10, _ Top:=10, Width:=50, Height:=60 .AddLine BeginX:=0, BeginY:=0, _ EndX:=70, EndY:=70 End With With shpCanvas .CanvasIte

5、ms(1).Fill.ForeColor _ .RGB = RGB(Red:=255, Green:=0, Blue:=0) .CanvasItems(2).Line _ .EndArrowheadStyle = msoArrowheadTriangle End WithEnd Sub3.添加一條貝賽爾曲線本例向活動(dòng)文檔添加一條兩段的貝塞爾曲線,并且將其定位在第二段(文檔中至少要有兩段,否則出錯(cuò))。選擇曲線,右擊可編輯頂點(diǎn)。Sub BezierCurve() Dim sngArray(1 To 7, 1 To 2) As Single sngArray(1, 1) = 0 sngArray(1

6、, 2) = 0 sngArray(2, 1) = 72 sngArray(2, 2) = 72 sngArray(3, 1) = 100 sngArray(3, 2) = 40 sngArray(4, 1) = 20 sngArray(4, 2) = 50 sngArray(5, 1) = 90 sngArray(5, 2) = 120 sngArray(6, 1) = 60 sngArray(6, 2) = 30 sngArray(7, 1) = 150 sngArray(7, 2) = 90 ActiveDocument.Shapes.AddCurve SafeArrayOfPoints

7、:=sngArray, Anchor:=ActiveDocument.Paragraphs(2).RangeEnd Sub4.繪制正弦曲線'在Word中畫正弦曲線Sub DrawSin() Dim i As Single, x1 As Single, x2 As Single, x As Single, n As Single Dim sngArray(1 To 100, 1 To 2) As Single Const PI As Single = 3.1415 x1 = 0 '初始角度值 x2 = 1440 '終止角度值 x = 1440 '終初角度差 n = x / 360 '波數(shù) For i = 1 To 100 sngArray(i, 1) = 100 + 2 * i sngArray(i, 2) = 200 - 30 * Sin(4 * n * P

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論