您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 资本运营 > 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
本文标题:VB调用WORD方法与实例代码
链接地址:https://www.777doc.com/doc-4892325 .html