Excel VBA相当于Word VBA系统

我有一个Word VBA函数,我想在Excel VBA(这个select背后的原因来自这个问题 ),我被困在以下问题:

Word VBA函数广泛使用System.PrivateProfileString ,当应用于Excel VBA时会引发Compile Error: invalid qualifier错误。 Excel中的等效语句是什么? 或者,我该如何解决这个问题?

使用示例:

 strHomeSharePath = System.PrivateProfileString("", "HKEY_CURRENT_USER\Volatile Environment", "HOMESHARE") 

嗨,如果你用魔杖阅读Excel中的regesty,你可以这样做。

 Sub test() Dim strPath As String strPath = RegKeyRead("HKEY_CURRENT_USER\Volatile Environment\HOMESHARE") End Sub Function RegKeyRead(i_RegKey As String) As String Dim myWS As Object On Error Resume Next 'access Windows scripting Set myWS = CreateObject("WScript.Shell") 'read key from registry RegKeyRead = myWS.RegRead(i_RegKey) End Function 

假设(根据你的其他问题)你的Excel代码有一个单词对象的引用,让我们说“objWord”,它应该是…

 strHomeSharePath = objWord.System.PrivateProfileString("", "HKEY_CURRENT_USER\Volatile Environment", "HOMESHARE") 

国际海事组织的“系统”一词有点误导,表明这不是与Word。 但是它是Word库中的一个类。