Hello All,
My VBA experience is very limited, but hoping someone can help me with the following;
Since a systems update at work, were they replaced all our desktops, I've been getting an error when opening an Excel report. Please find attached screenshot of the compile error. This is where my knowledge is very limited, in my VBA code there is a declare statement that needs updating because my system is now 64bit. I have found the statement but I have no idea how I can make it work.
This is the issue:
Here is the full code:
I would be very grateful if anyone could help me with this.
Regards,
My VBA experience is very limited, but hoping someone can help me with the following;
Since a systems update at work, were they replaced all our desktops, I've been getting an error when opening an Excel report. Please find attached screenshot of the compile error. This is where my knowledge is very limited, in my VBA code there is a declare statement that needs updating because my system is now 64bit. I have found the statement but I have no idea how I can make it work.
This is the issue:
Rich (BB code):
Private Declare Function CoCreateGuid Lib "OLE32.DLL" (pGuid As GUID) As Long
Here is the full code:
Rich (BB code):
Option Explicit
'Option Private Module
Private Declare Function CoCreateGuid Lib "OLE32.DLL" (pGuid As GUID) As Long
Private Type GUID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(7) As Byte
End Type
Private Sub Guidtest()
Debug.Print GetGUID
End Sub
Public Function GetGUID() As String
'(c) 2000 Gus Molina
Dim udtGUID As GUID
Dim Temp As String
Dim Ret As String
If (CoCreateGuid(udtGUID) = 0) Then
Temp = _
String(8 - Len(Hex$(udtGUID.Data1)), "0") & Hex$(udtGUID.Data1) & _
String(4 - Len(Hex$(udtGUID.Data2)), "0") & Hex$(udtGUID.Data2) & _
String(4 - Len(Hex$(udtGUID.Data3)), "0") & Hex$(udtGUID.Data3) & _
IIf((udtGUID.Data4(0) < &H10), "0", "") & Hex$(udtGUID.Data4(0)) & _
IIf((udtGUID.Data4(1) < &H10), "0", "") & Hex$(udtGUID.Data4(1)) & _
IIf((udtGUID.Data4(2) < &H10), "0", "") & Hex$(udtGUID.Data4(2)) & _
IIf((udtGUID.Data4(3) < &H10), "0", "") & Hex$(udtGUID.Data4(3)) & _
IIf((udtGUID.Data4(4) < &H10), "0", "") & Hex$(udtGUID.Data4(4)) & _
IIf((udtGUID.Data4(5) < &H10), "0", "") & Hex$(udtGUID.Data4(5)) & _
IIf((udtGUID.Data4(6) < &H10), "0", "") & Hex$(udtGUID.Data4(6)) & _
IIf((udtGUID.Data4(7) < &H10), "0", "") & Hex$(udtGUID.Data4(7))
Ret = Left(Temp, 8) & "-"
Ret = Ret & Mid(Temp, 9, 4) & "-"
Ret = Ret & Mid(Temp, 13, 4) & "-"
Ret = Ret & Mid(Temp, 17, 4) & "-"
Ret = Ret & Mid(Temp, 21)
Ret = "{" & Ret & "}"
GetGUID = Ret
End If
End Function
I would be very grateful if anyone could help me with this.
Regards,
Attachments
Last edited by a moderator: