VBA在Excel 2013中打开URL,64位

我试图通过vba打开链接,但我有很多问题,这是我以前使用的:

Sub OpenUrl() With Application .ScreenUpdating = False .EnableEvents = False .Calculation = xlCalculationManual .DisplayAlerts = False End With Dim lSuccess As Long Dim LastRow as Long LastRow = Range("A65536").End(xlUp).Row For Cell = LastRow To 1 Step -1 'lSuccess = ShellExecute(0, "Open", Range("D" & Cell).Value) ThisWorkbook.FollowHyperlink (Range("D" & Cell).Value) Next Cell With Application .ScreenUpdating = True .EnableEvents = True .Calculation = xlCalculationAutomatic .DisplayAlerts = True End With End Sub 

但是,当它到达ThisWorkbook.Followhyperlink部分它会引发“内存不足”,即使我的系统有64GB的内存。

尝试执行从下面的执行路线的shell: http : //support.microsoft.com/kb/224816不能为我工作,因为它返回:

http://i.imgur.com/qiAe0o0.png

有人有主意吗?

如果您在64位办公室使用API​​,则可能需要将其声明为“指针安全”,并使用VBA7 LongPtrtypes。 您可以使用条件编译来使用VBA7 Win64常量testing环境:

 #If Win64 Then Private Declare PtrSafe Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"( _ ByVal hwnd As LongPtr, ByVal lpOperation As String, ByVal lpFile As String, _ ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As LongPtr) As Long #Else Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA"( _ ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, _ ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long #End If 

有关详细信息,请参阅此MSDN文章,了解32位和64位Office与VBA之间的兼容性