找回密码
 加入
搜索
查看: 1668|回复: 6

[系统综合] ObjCreate创建WPS2019个人版问题

[复制链接]
发表于 2020-12-28 11:57:45 | 显示全部楼层 |阅读模式
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")可以兼容
发表于 2020-12-28 12:16:13 | 显示全部楼层
可能是个人版没有VBA组件
 楼主| 发表于 2020-12-28 13:58:36 | 显示全部楼层
zghwelcome 发表于 2020-12-28 12:16
可能是个人版没有VBA组件

个人版有VBA组件
发表于 2020-12-29 17:04:07 | 显示全部楼层
$oExcel = ObjGet("", "Excel.Application")
 楼主| 发表于 2020-12-29 23:32:44 | 显示全部楼层
本帖最后由 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

发表于 2020-12-31 20:48:11 | 显示全部楼层
注册表这么多啊
 楼主| 发表于 2021-1-3 19:35:07 | 显示全部楼层
本帖最后由 121044246 于 2021-1-3 19:38 编辑

我重新整理了,写成AU3自动获取WPS安装路径,先备份原注册表再写入新的注册表,代码再楼上。X64的有3个,X86有2个位置,
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-16 13:05 , Processed in 0.108911 second(s), 19 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表