

EXCEL FONT PICKER CODE
Misconception: “You should change all Long variables in your Declare Statements and Type declarations to be LongPtr variables when adapting your code for 64-bit.”Īs mentioned above, the size of the existing, generic 32-bit data types has not changed. You can use this data type in both environments and it will always be appropriately sized to handle the pointer size of your environment. LongPtr is the perfect type for any pointer or handle in your Declare Statement. The really clever thing about the LongPtr type is, it is a 32-bit Integer if the code runs in 32-bit VBA and it becomes a 64-bit Integer if the code runs in 64-bit VBA. Particularly for pointers, Microsoft introduced an all new and very clever data type.

In theory, you could use the new LongLong type to declare integer pointer variables in 64-bit VBA code. So, obviously, we cannot use the unchanged Long data type anymore. On 64-bit Windows, these pointers were changed to 64-bit Integers to address the larger memory space.

In VBA, we used to declare those pointer variables as Long. On 32-bit Windows, all pointers to memory addresses are 32-bit Integers. Here is the Excel code to pull the list of fonts (which would suffice) from the commandbar Only solution I have found is to purchase Total Visual sourcebook Some suggestions here that it does not exist for 64bit. '************ Code End ***********I have googled this and have not found a thread with any success. LF.lfHeight = -MulDiv(CLng(f.Height), GetDeviceCaps(GetDC(hWndAccessApp), LOGPIXELSY), 72)Ĭall StringToByte(f.Name, LF.lfFaceName())ĬopyMemory ByVal lLogFontAddress, LF, Len(LF)įS.Flags = CF_SCREENFONTS Or CF_EFFECTS Or CF_INITTOLOGFONTSTRUCTĬopyMemory LF, ByVal lLogFontAddress, Len(LF)įunction test_DialogFont(ctl As Control) As Booleanĭebug.Print "Font Underline: ". Public Function DialogFont(ByRef f As FormFontInfo) As Booleanĭim lLogFontAddress As Long, lMemHandle As Long While dwBytePoint intUbound - intLbound Then intLen = intUbound - intLboundīyteArray(intX - 1 + intLbound) = Asc(Mid(InString, intX, 1)) Private Function ByteToString(aBytes() As Byte) As Stringĭim dwBytePoint As Long, dwByteVal As Long, szOut As String Private Function MulDiv(In1 As Long, In2 As Long, In3 As Long) As Long Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long (ByVal hdc As Long, ByVal nIndex As Long) As Long Private Declare Function GetDeviceCaps Lib "gdi32" _ (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long) Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _ (ByVal wFlags As Long, ByVal dwBytes As Long) As Long Private Declare Function GlobalAlloc Lib "kernel32" _ Private Declare Function GlobalLock Lib "kernel32" (ByVal hMem As Long) As Long Private Declare Function ChooseFont Lib "comdlg32.dll" Alias "ChooseFontA" _ Private Const CF_NOOEMFONTS = CF_NOVECTORFONTS Private Const CF_BOTH = (CF_SCREENFONTS Or CF_PRINTERFONTS) Private Const CF_SCRIPTSONLY = CF_ANSIONLY Private Const CF_INITTOLOGFONTSTRUCT = &H40& Private Const CF_FORCEFONTEXIST = &H10000 Private Const CF_FIXEDPITCHONLY = &H4000& Private Const CF_ENABLETEMPLATEHANDLE = &H20& Private Const GHND = (GMEM_MOVEABLE Or GMEM_ZEROINIT)
