Board logo

标题: [问题求助] vbs 调用excel api [打印本页]

作者: czjt1234    时间: 2018-4-29 15:42     标题: 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()
复制代码
这个怎么一直找不到窗口的
作者: czjt1234    时间: 2018-4-30 13:38

用dynwrap.dll这个可以的

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




欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2