[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
两个错误:
1、Paste:=xlValues 是 vba 的内部参数赋值方式
2、xlValues 是 excel 的常量,在 vbs 中尚未定义

改下应该就好了:
  1. Const xlPasteAll=-4104
  2. Const xlPasteAllExceptBorders=7
  3. Const xlPasteColumnWidths=8
  4. Const xlPasteComments=-4144
  5. Const xlPasteFormats=-4122
  6. Const xlPasteFormulas=-4123
  7. Const xlPasteFormulasAndNumberFormats=11
  8. Const xlPasteValidation=6
  9. Const xlPasteValues=-4163
  10. Const xlPasteValuesAndNumberFormats=12
  11. '定义 excel 中的各种常量,不定义直接引用数值也可,不过可读性欠佳
  12. Set oWord = CreateObject("Word.Application")
  13. oWord.Visible = False     
  14. Set objDoc = oWord.Documents.Open("c:\aa.doc")
  15. Set oExcel = CreateObject("Excel.Application")
  16. oExcel.Visible = True  
  17. Set oWb = oExcel.Workbooks.Open("C:\aa.xls")
  18. Set xlsheet = oExcel.Worksheets("sheet1")
  19. oWord.ActiveDocument.Tables(3).Cell(3,3).Select
  20. oWord.Selection.Copy
  21. xlsheet.Cells(1,1).PasteSpecial xlPasteValues
  22. oWord.Quit
  23. Set oWord = Nothing
  24. Set objDoc = Nothing
  25. Set fso = Nothing
  26. Set oread = Nothing
  27. Set oExcel = Nothing
  28. Set oWb = Nothing
  29. Set xlsheet = Nothing
复制代码

TOP

返回列表