在WPS中使用VBA7

2021-07-13 06:49:36 字數 2498 閱讀 7173

從microsoft shared和system32中提取出vba及其依賴的基本檔案,複製並設定登錄檔

後,即可讓wps 2012使用vba7。但似乎wps2012只認放在office10中的mso.dll。 

所需的檔案有:

vba目錄(只需vba6、vba7中的vbe6ext.olb,vbe7.dll和2052),

office10目錄(只需mso.dll及1033或2052目錄下msointl.dll,可取最新版本),

system32下fm20.dll,fm20chs.dll,fm20enu.dll檔案,

提取之後執行批處理指令碼set.bat自動複製和設定。

在win xp中雙擊set.bat,在win7中需在set.bat上點右鍵,以管理員身份執行。

wps 2012中:alt + f8 執行巨集,alt + f11 開啟巨集編輯器。

set.bat中的批處理命令:

md "%commonprogramfiles%\microsoft shared\office10"

md "%commonprogramfiles%\microsoft shared\vba"

xcopy /i /s /-y %~dp0\office10 "%commonprogramfiles%\microsoft shared\office10"

xcopy /i /s /-y %~dp0\vba "%commonprogramfiles%\microsoft shared\vba"

xcopy /i /s /-y %~dp0\system32 "%systemroot%\system32\"

reg import %~dp0\vba7.reg

regsvr32 /s "%commonprogramfiles%\microsoft shared\vba\vba7\vbe7.dll"

regsvr32 /s "%systemroot%\system32\fm20.dll"

@echo "檔案已複製。登錄檔檔案已匯入。dll已登記。"

@pause

vbe7.reg中的內容:

windows registry editor version 5.00

[hkey_local_machine\software\microsoft\vba]

"vbe6dllpath"="c:\\program files\\common files\\microsoft shared\\vba\\vba7\\vbe7.dll"

"vbe7dllpath"="c:\\program files\\common files\\microsoft shared\\vba\\vba7\\vbe7.dll"

[hkey_local_machine\software\classes\typelib\]

[hkey_local_machine\software\classes\typelib\\5.3]

"primaryinteropassemblyname"="microsoft.vbe.interop, version=14.0.0.0, culture=neutral, publickeytoken=71e9bce111e9429c"

[hkey_local_machine\software\classes\typelib\\5.3\0]

[hkey_local_machine\software\classes\typelib\\5.3\0\win32]

@="c:\\program files\\common files\\microsoft shared\\vba\\vba6\\vbe6ext.olb"

[hkey_local_machine\software\classes\typelib\\5.3\flags]

@="0"

[hkey_local_machine\software\classes\typelib\\5.3\helpdir]

@=""

[hkey_classes_root\typelib\\4.1]

[hkey_classes_root\typelib\\4.1]

[hkey_classes_root\typelib\\4.1\9]

[hkey_classes_root\typelib\\4.1\9\win32]

[hkey_classes_root\typelib\\4.1\9\win32]

@="c:\\program files\\common files\\microsoft shared\\vba\\vba7\\vbe7.dll"

[hkey_classes_root\typelib\\4.1\flags]

[hkey_classes_root\typelib\\4.1\flags]

@="0"

[hkey_classes_root\typelib\\4.1\helpdir]

[hkey_classes_root\typelib\\4.1\helpdir]

@="c:\\program files\\common files\\microsoft shared\\vba\\vba7"

在 VBA 中使用 SQL 處理資料

sub 使用sql處理資料 false 建立資料庫相關物件 建立資料庫連線 dim cnn as object set cnn createobject adodb.connection 建立 包含描述資料來源模式目錄的集合 dim mycat as object set mycat createo...

VBA高階 在VBA中使用SQL語句篩選日期

sub multipleselect group1 dim cnn as new adodb.connection dim rst as adodb.recordset dim mypath as string dim sql as string dim i as integer dim d as ...

EXCEL中使用VBA取有效使用區域

原創 牛超 2009 06 osaka 如題,修改原來的指令碼,引用usedrange private sub fillvalueauto astr as string,currow as long dim svalue as string dim sbatname as string dim sp...