




已閱讀5頁,還剩4頁未讀, 繼續(xù)免費(fèi)閱讀
版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡介
1、返回Word文檔的段落文字,控制分頁,設(shè)置頁眉和頁腳vbview plaincopy1. 先引用MicrosoftWord11.0ObjectLibrary2. OptionExplicit3. 4. DimWordAppAsWord.Application創(chuàng)建Word應(yīng)用程序5. 6. PrivateSubCommand1_Click()7. DimiAsLong8. OnErrorGoToErrhandler9. CommonDialog1.Filter=Word(*.Doc)|*.Doc|AllFile(*.*)|*.*10. CommonDialog1.FilterIndex=111. CommonDialog1.ShowOpen12. SetWordApp=NewWord.Application實(shí)例化13. WordApp.Documents.OpenCommonDialog1.FileName打開Word文件14. WordApp.Visible=True顯示OfficeWord界面15. 或者Application.Visible=True16. WordApp.DisplayAlerts=False不提示保存對(duì)話框17. 18. 返回段落文字,返回的段落文字在文本框控件中19. Text1.Text=20. Fori=1ToActiveDocument.Paragraphs.Count21. Text1.Text=Text1.Text&(ActiveDocument.Paragraphs(i).Range.Text&vbCrLf&vbCrLf)22. Next23. 24. 控制分頁25. WordApp.Selection.EndKeyunit:=wdStory將光標(biāo)移到文檔末尾26. WordApp.Selection.InsertBreakwdPageBreak在文檔末尾插入一頁27. 28. 設(shè)置圖片格式的頁眉29. IfActiveWindow.View.SplitSpecialwdPaneNoneThen30. ActiveWindow.Panes(2).Close31. EndIf32. IfActiveWindow.ActivePane.View.Type=wdNormalViewOrActiveWindow.ActivePane.View.Type=wdOutlineViewThen33. ActiveWindow.ActivePane.View.Type=wdPrintView34. EndIf35. ActiveWindow.ActivePane.View.SeekView=wdSeekCurrentPageHeader36. Selection.InlineShapes.AddPictureFileName:=F:資料MyPictures2013年元旦.gif,LinkToFile:=False,SaveWithDocument:=True加載一圖片文件作為頁眉37. Selection.ParagraphFormat.Alignment=wdAlignParagraphLeft38. ActiveWindow.ActivePane.View.SeekView=wdSeekMainDocument39. 40. 設(shè)置文本格式的頁眉41. IfActiveWindow.View.SplitSpecialwdPaneNoneThen42. ActiveWindow.Panes(2).Close43. EndIf44. IfActiveWindow.ActivePane.View.Type=wdNormalViewOrActiveWindow.ActivePane.View.Type=wdOutlineViewThen45. ActiveWindow.ActivePane.View.Type=wdPrintView46. EndIf47. ActiveWindow.ActivePane.View.SeekView=wdSeekCurrentPageHeader48. Selection.TypeTextText:=辦公室常用工具49. ActiveWindow.ActivePane.View.SeekView=wdSeekMainDocument50. 51. 隱藏頁眉的橫線52. WordApp.ActiveDocument.Sections(1).Headers(wdHeaderFooterPrimary).Range.Borders(wdBorderBottom).Visible=False53. 54. 取得頁眉的內(nèi)容55. Debug.PrintWordApp.ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).Range.Text獲取WORD第一節(jié)的頁眉的文字內(nèi)容56. 57. 58. 設(shè)置頁腳59. IfActiveWindow.View.SplitSpecialwdPaneNoneThen60. ActiveWindow.Panes(2).Close61. EndIf62. IfActiveWindow.ActivePane.View.Type=wdNormalViewOrActiveWindow.ActivePane.View.Type=wdOutlineViewThen63. ActiveWindow.ActivePane.View.Type=wdPrintView64. EndIf65. ActiveWindow.ActivePane.View.SeekView=wdSeekCurrentPageHeader66. IfSelection.HeaderFooter.IsHeader=TrueThen67. ActiveWindow.ActivePane.View.SeekView=wdSeekCurrentPageFooter68. Else69. ActiveWindow.ActivePane.View.SeekView=wdSeekCurrentPageHeader70. EndIf71. Selection.TypeTextText:=2013年設(shè)置頁腳72. Selection.Fields.AddRange:=Selection.Range,Type:=wdFieldNumPages73. ActiveWindow.ActivePane.View.SeekView=wdSeekMainDocument74. 75. ActiveDocument.SaveAsc:MyWord.doc保存最后生成的word文檔76. 77. Errhandler:78. ExitSub79. EndSub80. 81. PrivateSubForm_Unload(CancelAsInteger)82. OnErrorResumeNext83. WordApp.Quit84. SetWordApp=Nothing85. EndSub 效果圖如下: 2、控制Word文檔中的文本框?qū)ο髒bview plaincopy1. 先引用MicrosoftWord11.0ObjectLibrary2. OptionExplicit3. 4. DimWordAppAsWord.Application創(chuàng)建Word應(yīng)用程序5. 6. PrivateSubCommand1_Click()7. OnErrorGoToErrhandler8. CommonDialog1.Filter=MSOfficeWord(*.Doc)|*.Doc|AllFile(*.*)|*.*9. CommonDialog1.FilterIndex=110. CommonDialog1.ShowOpen11. SetWordApp=NewWord.Application實(shí)例化12. WordApp.Documents.OpenCommonDialog1.FileName打開Word文件13. IfDocuments.Count=1Then14. Text1.Text=打開的Word文件是:&ActiveDocument.Name&vbCrLf&vbCrLf15. EndIf16. WordApp.Visible=True顯示OfficeWord界面17. 或者Application.Visible=True18. WordApp.DisplayAlerts=False不提示保存對(duì)話框19. 20. WordApp.Selection.EndKeyunit:=wdStory將光標(biāo)移到文檔末尾21. WordApp.Selection.Font.Bold=122. WordApp.Selection.Font.Name=黑體23. WordApp.Selection.Font.Size=1824. WordApp.Selection.TypeTextText:=在Word文件中插入文本框?qū)ο?5. WordApp.Selection.ParagraphFormat.Alignment=Word.WdParagraphAlignment.wdAlignParagraphCenter居中顯示26. 27. 創(chuàng)建文本框?qū)ο?座標(biāo)(100,100),寬度200,高度20028. WithActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal,100,100,400,300).Fill29. .Transparency=1設(shè)置透明色30. .ForeColor=vbRed設(shè)置前景顏色31. .UserPicture(F:資料MyPictures758254_960x1000_0.jpg)設(shè)置文本框?qū)ο蟮谋尘皥D片32. EndWith33. ActiveDocument.Shapes(1).TextFrame.TextRange.Text=這是一個(gè)美女給文本框賦值34. ActiveDocument.Shapes(1).Line.Transparency=1設(shè)置透明邊框線條35. 36. 再創(chuàng)建一個(gè)透明背景的文本框?qū)ο?7. WithActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal,100,400,400,300).Fill38. .Transparency=1設(shè)置透明色背景39. .ForeColor=vbRed設(shè)置前景顏色40. EndWith41. ActiveDocument.Shapes(2).TextFrame.TextRange.Text=這是一個(gè)透明背景的文本框給文本框賦值42. ActiveDocument.Shapes(2).Line.Transparency=1設(shè)置透明邊框線條43. 44. 下面是獲取文本框?qū)ο蟮膬?nèi)容45. DimiAsLong46. Fori=1ToActiveDocument.Shapes.Count47. Text1.Text=Text1.Text&(第&i&個(gè)文本框的內(nèi)容:&ActiveDocument.Shapes(i).TextFrame.TextRange.Text&vbCrLf)48. Next49. 50. ActiveDocument.SaveAsc:MyWord.doc保存最后生成的word文檔51. 52. Errhandler:53. ExitSub54. EndSub55. 56. PrivateSubForm_Unload(CancelAsInteger)57. OnErrorResumeNext58. WordApp.Quit59. SetWordApp=Nothing60. EndSub 效果圖如下: 3、在Word文檔中設(shè)置Excel風(fēng)格的頁碼vbview plaincopy1. 先引用MicrosoftWord11.0ObjectLibrary2. OptionExplicit3. 4. DimWordAppAsWord.Application創(chuàng)建Word應(yīng)用程序5. DimWordDocAsWord.Document創(chuàng)建Word文檔對(duì)象6. 7. PrivateSubCommand1_Click()8. DimiAsLong9. OnErrorGoToErrhandler10. CommonDialog1.Filter=Word(*.Doc)|*.Doc|AllFile(*.*)|*.*11. CommonDialog1.FilterIndex=112. CommonDialog1.ShowOpen13. SetWordApp=NewWord.Application實(shí)例化14. SetWordDoc=WordApp.Documents.Open(CommonDialog1.FileName)選擇并打開Word文件15. WordApp.Visible=True顯示OfficeWord界面16. 或者Application.Visible=True17. WordApp.DisplayAlerts=False不提示保存對(duì)話框18. 19. 設(shè)置Word文檔第一頁頁碼20. DimWordRangeAsRange21. SetWordRange=WordApp.ActiveDocument.Sections(1).Footers(wdHeaderFooterPrimary).Range22. 23. WithWordRange24. .InsertAfter第25. .Font.Size=1426. .CollapseDirection:=wdCollapseEnd27. 28. 插入頁碼域29. .Fields.AddRange:=WordRange,Type:=wdFieldEmpty,Text:=PAGE*Arabic,PreserveFormatting:=True30. .Expandunit:=wdWord31. .InsertAfter頁32
溫馨提示
- 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ì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 2025年中醫(yī)護(hù)理專業(yè)就業(yè)能力測試試題及答案
- 2025年網(wǎng)絡(luò)空間安全與防御能力考試試卷及答案
- 2025年土木工程與建筑材料考試試題及答案
- 2025年人工智能倫理與法律考試試卷及答案
- 2025年老年護(hù)理與健康管理專業(yè)能力測評(píng)考試卷及答案
- 2025年歷史與文化遺產(chǎn)知識(shí)測試卷及答案
- 2025年國際經(jīng)濟(jì)與貿(mào)易專業(yè)知識(shí)測試卷及答案
- 2025年公共藝術(shù)創(chuàng)作與策展課程考試試題及答案
- 2025年城市生態(tài)規(guī)劃師考試試題及答案
- 2024年度浙江省二級(jí)造價(jià)工程師之建設(shè)工程造價(jià)管理基礎(chǔ)知識(shí)自我提分評(píng)估(附答案)
- 內(nèi)科學(xué)(廣東藥科大學(xué))智慧樹知到期末考試答案2024年
- 再回首混聲合唱譜
- 2023年11月南昌高新技術(shù)產(chǎn)業(yè)開發(fā)區(qū)人民檢察院招考4名聘用制檢察輔助人員筆試近6年高頻考題難、易錯(cuò)點(diǎn)薈萃答案帶詳解附后
- 珍愛生命遠(yuǎn)離溺水風(fēng)險(xiǎn)
- 運(yùn)輸行業(yè)保密知識(shí)培訓(xùn)
- 南平市浦城縣石陂鎮(zhèn)社區(qū)工作者招聘考試基礎(chǔ)題匯總2023
- 產(chǎn)能管理制度
- 《汽車發(fā)動(dòng)機(jī)構(gòu)造與維修》(配實(shí)訓(xùn)工單) 教案 5-1冷卻系結(jié)構(gòu)與循環(huán)線路(4學(xué)時(shí))
- 員工反饋與投訴處理機(jī)制
- 《電力交易培訓(xùn)》課件
- 研究污水處理中的微生物群落結(jié)構(gòu)
評(píng)論
0/150
提交評(píng)論