ObjCreate创建WPS2019个人版问题
Local $oExcel = ObjCreate("wps.Application")Local $oExcel = ObjCreate("Kwps.Application")
Local $oExcel = ObjCreate("et.Application")
Local $oExcel = ObjCreate("Ket.Application")
Local $oExcel = ObjCreate("Excel.Application")网上搜了各种方法,全部无法调用WPS2019个人版,专业版的Local $oExcel = ObjCreate("Excel.Application")可以兼容 可能是个人版没有VBA组件 zghwelcome 发表于 2020-12-28 12:16
可能是个人版没有VBA组件
个人版有VBA组件 $oExcel = ObjGet("", "Excel.Application") 本帖最后由 121044246 于 2021-1-3 19:37 编辑
duxing 发表于 2020-12-29 17:04
$oExcel = ObjGet("", "Excel.Application")
谢谢,已经解决了。我的办法是修改注册表{00024500-0000-0000-C000-000000000046}将office的路径改成wps的,测试成功了。Wps_Path()
If @OSArch = "X64" Then
x64()
ElseIf @OSArch = "X86" Then
x86()
ElseIf @OSArch = "IA64" Then
MsgBox(0,"提示","暂不支持系统构架:"& @OSArch)
EndIf
Func Wps_Path()
$Wps_Path = RegRead('HKEY_CURRENT_USER\Software\Kingsoft\Office\6.0\Common','InstallRoot');获取WPS安装路径
If @error Then
$Wps_Path = RegRead('HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Kingsoft\Office\6.0\Common','InstallRoot');获取WPS安装路径
If @error Then
MsgBox(0,"提示","获取WPS安装路径失败!")
Exit
Else
EndIf
EndIf
;~ MsgBox(0,0,$Wps_Path)
Return $Wps_Path
EndFunc
Func x86();写入Excel.Application
;HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}
If RegEnumKey ('HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}',1) <> "" Then ShellExecute('reg', 'export HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046} '&@ScriptDir&"\H_C_R_C.reg")
RegWrite('HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}',"","REG_SZ", "Microsoft Excel Application")
RegWrite('HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}\InprocHandler32',"","REG_SZ", "ole32.dll")
RegWrite('HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32',"Assembly","REG_SZ", "Microsoft.Office.Interop.Excel, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C")
RegWrite('HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32',"Class","REG_SZ", "Microsoft.Office.Interop.Excel.ApplicationClass")
RegWrite('HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32',"RuntimeVersion","REG_SZ", "v2.0.50727")
RegWrite('HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\3.0.0.0',"Assembly","REG_SZ", "Kingsoft.Office.Interop.Etapi, Version=3.0.0.0, Culture=neutral, PublicKeyToken=15d99fb7f8fe5cb4")
RegWrite('HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\3.0.0.0',"Class","REG_SZ", "Excel.ApplicationClass")
RegWrite('HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\3.0.0.0',"RuntimeVersion","REG_SZ", "v2.0.50727")
RegWrite('HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer32',"","REG_SZ", $Wps_Path&"\office6\et.exe /Automation")
RegWrite('HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}\ProgID',"","REG_SZ", "Excel.Application.12")
RegWrite('HKEY_CLASSES_ROOT\CLSID\{00024500-0000-0000-C000-000000000046}\VersionIndependentProgID',"","REG_SZ", "Excel.Application")
;HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}
If RegEnumKey ('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}',1) <> "" Then ShellExecute('reg', 'export HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046} '&@ScriptDir&"\H_L_M_S_C_C.reg")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}',"","REG_SZ","Microsoft Office Excel 应用程序")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\InprocHandler32',"","REG_SZ","ole32.dll")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32',"Assembly","REG_SZ","Kingsoft.Office.Interop.Etapi, Version=3.0.0.0, Culture=neutral, PublicKeyToken=15d99fb7f8fe5cb4")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32',"Class","REG_SZ","Excel.ApplicationClass")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32',"RuntimeVersion","REG_SZ","v2.0.50727")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\3.0.0.0',"Assembly","REG_SZ","Kingsoft.Office.Interop.Etapi, Version=3.0.0.0, Culture=neutral, PublicKeyToken=15d99fb7f8fe5cb4")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\3.0.0.0',"Class","REG_SZ","Excel.ApplicationClass")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\3.0.0.0',"RuntimeVersion","REG_SZ","v2.0.50727")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer32',"","REG_SZ",$Wps_Path&"\office6\et.exe /Automation")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer32',".ksobak","REG_SZ","")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer32',"LocalServer32","REG_MULTI_SZ", '"'&$Wps_Path&'\office6\et.exe" /Automation')
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\ProgID',"","REG_SZ","Excel.Application.12")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\ProgID',".ksobak","REG_SZ","Excel.Application.11")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\VersionIndependentProgID',"","REG_SZ","Excel.Application")
EndFunc
Func x64()
;HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}
If RegEnumKey ('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}',1) <> "" Then ShellExecute('reg', 'export HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046} '&@ScriptDir&"\H_C_R_W_C.reg")
RegWrite('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}',"","REG_SZ","Microsoft Office Excel 应用程序")
RegWrite('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\InprocHandler32',"","REG_SZ","ole32.dll")
RegWrite('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32',"Assembly","REG_SZ","Kingsoft.Office.Interop.Etapi, Version=3.0.0.0, Culture=neutral, PublicKeyToken=15d99fb7f8fe5cb4")
RegWrite('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32',"Class","REG_SZ","Excel.ApplicationClass")
RegWrite('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32',"RuntimeVersion","REG_SZ","v2.0.50727")
RegWrite('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\3.0.0.0',"Assembly","REG_SZ","Kingsoft.Office.Interop.Etapi, Version=3.0.0.0, Culture=neutral, PublicKeyToken=15d99fb7f8fe5cb4")
RegWrite('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\3.0.0.0',"Class","REG_SZ","Excel.ApplicationClass")
RegWrite('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\3.0.0.0',"RuntimeVersion","REG_SZ","v2.0.50727")
RegWrite('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer32',"","REG_SZ",$Wps_Path&"\office6\et.exe /Automation")
RegWrite('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer32',".ksobak","REG_SZ","")
RegWrite('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer32',"LocalServer32","REG_MULTI_SZ", '"'&$Wps_Path&'\office6\et.exe" /Automation')
RegWrite('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\ProgID',"","REG_SZ","Excel.Application.12")
RegWrite('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\ProgID',".ksobak","REG_SZ","Excel.Application.11")
RegWrite('HKEY_CLASSES_ROOT\Wow6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\VersionIndependentProgID',"","REG_SZ","Excel.Application")
;HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}
If RegEnumKey ('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}',1) <> "" Then ShellExecute('reg', 'export HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046} '&@ScriptDir&"\H_L_M_S_C_W_C.reg")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}',"","REG_SZ","Microsoft Office Excel 应用程序")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\InprocHandler32',"","REG_SZ","ole32.dll")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32',"Assembly","REG_SZ","Kingsoft.Office.Interop.Etapi, Version=3.0.0.0, Culture=neutral, PublicKeyToken=15d99fb7f8fe5cb4")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32',"Class","REG_SZ","Excel.ApplicationClass")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32',"RuntimeVersion","REG_SZ","v2.0.50727")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\3.0.0.0',"Assembly","REG_SZ","Kingsoft.Office.Interop.Etapi, Version=3.0.0.0, Culture=neutral, PublicKeyToken=15d99fb7f8fe5cb4")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\3.0.0.0',"Class","REG_SZ","Excel.ApplicationClass")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\3.0.0.0',"RuntimeVersion","REG_SZ","v2.0.50727")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer32',"","REG_SZ",$Wps_Path&"\office6\et.exe /Automation")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer32',".ksobak","REG_SZ","")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer32',"LocalServer32","REG_MULTI_SZ", '"'&$Wps_Path&'\office6\et.exe" /Automation')
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\ProgID',"","REG_SZ","Excel.Application.12")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\ProgID',".ksobak","REG_SZ","Excel.Application.11")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\Classes\WOW6432Node\CLSID\{00024500-0000-0000-C000-000000000046}\VersionIndependentProgID',"","REG_SZ","Excel.Application")
;HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}
If RegEnumKey ('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}',1) <> "" Then ShellExecute('reg', 'export HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046} '&@ScriptDir&"\H_L_M_S_W_C_C.reg")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}',"","REG_SZ","Microsoft Office Excel 应用程序")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\InprocHandler32',"","REG_SZ","ole32.dll")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32',"Assembly","REG_SZ","Kingsoft.Office.Interop.Etapi, Version=3.0.0.0, Culture=neutral, PublicKeyToken=15d99fb7f8fe5cb4")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32',"Class","REG_SZ","Excel.ApplicationClass")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32',"RuntimeVersion","REG_SZ","v2.0.50727")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\3.0.0.0',"Assembly","REG_SZ","Kingsoft.Office.Interop.Etapi, Version=3.0.0.0, Culture=neutral, PublicKeyToken=15d99fb7f8fe5cb4")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\3.0.0.0',"Class","REG_SZ","Excel.ApplicationClass")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\InprocServer32\3.0.0.0',"RuntimeVersion","REG_SZ","v2.0.50727")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer32',"","REG_SZ",$Wps_Path&"\office6\et.exe /Automation")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer32',".ksobak","REG_SZ","")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\LocalServer32',"LocalServer32","REG_MULTI_SZ", '"'&$Wps_Path&'\office6\et.exe" /Automation')
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\ProgID',"","REG_SZ","Excel.Application.12")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\ProgID',".ksobak","REG_SZ","Excel.Application.11")
RegWrite('HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Classes\CLSID\{00024500-0000-0000-C000-000000000046}\VersionIndependentProgID',"","REG_SZ","Excel.Application")
EndFunc
注册表这么多啊 本帖最后由 121044246 于 2021-1-3 19:38 编辑
smallan 发表于 2020-12-31 20:48
注册表这么多啊
我重新整理了,写成AU3自动获取WPS安装路径,先备份原注册表再写入新的注册表,代码再楼上。X64的有3个,X86有2个位置,
页:
[1]