VB调用WORD方法与实例代码

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

'=============´ò¿ªword==============FunctionOpenWord(FileName)DimwordAppAsNewWord.ApplicationDimwordDocAsNewWord.DocumentSetwordApp=CreateObject(Word.Application)wordApp.Visible=FalseSetwordDoc=wordApp.Documents.Open(FileName)EndFunction'============Ìæ»»¹Ø¼ü×Ö===========FunctionReplaceWord(SearchStr,ReplaceStr)Selection.Find.ClearFormattingSelection.Find.Replacement.ClearFormattingWithSelection.Find.Text=SearchStr.Replacement.Text=ReplaceStr.Forward=True.Wrap=wdFindContinue.Format=False.MatchCase=False.MatchWholeWord=False.MatchByte=True.MatchWildcards=False.MatchSoundsLike=False.MatchAllWordForms=FalseEndWithSelection.Find.ExecuteReplace:=wdReplaceAllEndFunction'============Áí´æΪ===================FunctionSaveAsWord(DiskStr,NameStr)ChangeFileOpenDirectoryDiskStrActiveDocument.SaveAsFileName:=NameStr,FileFormat:=wdFormatDocument,_LockComments:=False,Password:=,AddToRecentFiles:=True,_WritePassword:=,ReadOnlyRecommended:=False,EmbedTrueTypeFonts:=False,_SaveNativePictureFormat:=False,SaveFormsData:=False,SaveAsAOCELetter:=FalseApplication.Documents.CloseApplication.QuitEndFunction'===================Çå³ý¶ÔÏó============FunctionCloseWord()SetwordDoc=Nothing'Çå³ýÎļþʵÀýSetwordApp=Nothing'Çå³ýWORDʵÀýEndFunction'===================ÓÃVBµ÷ÓÃWORD´úÂë============PrivateSubForm_Load()DimwpAsNewWord.ApplicationDimwdAsNewWord.Documentwp.Visible=TrueSetwd=wp.Documents.Open(c:\22075847937.doc)DimneirongAsStringneirong=wd.Content.TextMsgBox¸ÃWordÎļþµÄÄÚÈÝΪ£º&vbNewLine&neirongEndSub

1 / 2
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功