[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

[问题求助] vbs 调用excel api

  1. Option Explicit
  2. Dim oWS, oFSO, oExcel, s
  3. Set oWS    = CreateObject("WScript.Shell")
  4. Set oFSO   = CreateObject("Scripting.FileSystemObject")
  5. Set oExcel = CreateObject("Excel.Application")
  6. oExcel.DisplayAlerts = False
  7. s = "HKEY_CURRENT_USER\Software\Microsoft\Office\$\Excel\Security\AccessVBOM"
  8. oWS.RegWrite Replace(s, "$", oExcel.Version), 1, "REG_DWORD"
  9. s = "Private Declare Function FindWindow Lib ""user32"" Alias ""FindWindowA"" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long"
  10. oExcel.Workbooks.Add.VBProject.VBComponents.Add(1).CodeModule.AddFromString s
  11. oWS.Run "%windir%\system32\calc.exe"
  12. MsgBox "下面查找新打开的标题栏:计算器", vbSystemModal
  13. s = oExcel.Run("FindWindow", vbNullString, "计算器")
  14. MsgBox "窗口句柄: " & s
  15. oExcel.Quit()
复制代码
这个怎么一直找不到窗口的

QQ 20147578

用dynwrap.dll这个可以的

估计是vbs把vbNullString转换为""后传递参数了

QQ 20147578

TOP

返回列表