求助matlab notebook 代码运行不了

2024-11-15 02:27:32
推荐回答(1个)
回答1:

你好,我在别的地方也看你的提问,我来回答你;
  matlab提供notebook工具箱,可以让我们在word运行matlab代码,这是一个非常方便的功能,但是如果你的office和matlab是安装在64位的机子上的话,可能会报以下错误:
  这时候实在令人抓狂,因为我一开始还以为是由于我的word与matlab版本不对应,所以运行不了notebook,但是经过google后,可以通过修改以下代码就可以修复:

  添加PtrSafe属性,将:
  Private Declare Function WinHelp Lib "USER32.DLL" Alias "WinHelpA" (ByVal hWnd As Integer, ByVal lpHelpFile _
  As String, ByVal wCmd As Integer, ByVal dwData As String) As Integer
  Private Declare Function GetActiveWindow Lib "USER32.DLL" () As Integer
  改为:
  Private Declare PtrSafe Function WinHelp Lib "USER32.DLL" Alias "WinHelpA" (ByVal hWnd As Integer, ByVal lpHelpFile _
  As String, ByVal wCmd As Integer, ByVal dwData As String) As Integer
  Private Declare PtrSafe Function GetActiveWindow Lib "USER32.DLL" () As Integer