mdsk.net
当前位置:首页 >> 怎么能运用ExCEl的vBA读取worD文档中的内容 >>

怎么能运用ExCEl的vBA读取worD文档中的内容

Sub AAA() Dim FilePath As String '要读取的文件路径 Dim S1 As String '文档的内容 Dim S2 As String '提取到的内容 Dim Ar As Variant '用于保存最终结果 Dim L1 As Long '记录当前查找到的字符位置 FilePath = Application.GetSaveAsFilenam...

可用CreateObject函数创建对EXCEL的引用,然后就可打开EXCEL工作簿,将表格中的数据复制到WORD中,参考代码如下: Set xlapp = CreateObject("excel.application")With xlapp.Open("带路径的EXCEL文件名") .Sheets(1).Range("A1:H8").Copy '粘贴...

在word vba工具-引用中选中Ms Excel就可以正常打开EXCEL进行操作了 Dim xlapp As Excel.Application ‘代表excel程序 Dim wkBook As Excel.Workbook '代表excelworkbook(也就是excel工作簿文件 .xls .xlsx) Dim wkSheet As Excel.Worksheet '代...

'首先要在vba中引用Microsoft Word 11.0 Object Library Dim Wdapp As Word.Application Dim WdDocument As Word.Document Dim UserFile As String Private Sub CommandButton1_Click() Set Wdapp = New Word.Application UserFile = Wdapp.Path...

试一下以下代码, 祝你成功! Dim fcc,fo,fso Set fso = CreateObject("Scripting.filesystemobject") Set fo = fso.getfolder("C:\AA")'文件夹 i=1 For Each fc In fo.subFolders For Each fcc In fc.Files If InStr(1, fcc.Name, ".doc", 1) The...

试试下面的代码,在网上找的 Sub 宏1() Dim wordapp As Object Dim mydoc Dim mypath$, myname$ Dim wdRng As Object Dim pos1%, pos2% '定义找到的字段的首位位置 Application.DisplayAlerts = False Set wordapp = CreateObject("word.applica...

下面的代码调试通过,是不是应该考虑加分: Sub SAMPLE()'批量添加打开文档密码 Dim myDialog As FileDialog, oFile As Variant, oWord, oDoc 'On Error Resume Next Dim myPassWord As String myPassWord = "tangqingfu" '定义一个文件夹选取对...

你好twtytei,Sub abc() Dim App, WrdDoc, Mypath As String, StrA As String, StrB As String Mypath = "文件实际路径\TEXT1.doc" '请修改实际储存路径! Set App = CreateObject("Word.Application") '用Set关键字创建Word应用成序对象! App....

参考这个:Sub ExcelToWord() ' 利用Word程序创建文本文件 Dim WordApp As Object Dim Records As Integer, i As Integer Dim Region As String, SalesAmt As String, SalesNum As String, strTitle As String Set WordApp = CreateObject("Word....

'代码已经测试过,请注意保持良好习惯,及时采纳,谢谢。 Sub PasteToWordDoc() ' ' 需要引用MIcrosoft Word 12.0 Object Library(注:12.0是版本号,可以不同) ' Application.ScreenUpdating = False '关闭屏幕刷新' Selection.Copy Dim wdAp...

网站首页 | 网站地图
All rights reserved Powered by www.mdsk.net
copyright ©right 2010-2021。
内容来自网络,如有侵犯请联系客服。zhit325@qq.com