64位OfficeAPI声明语句第116讲

VBA语言専攻 2024-03-06 19:11:21

跟我学VBA,我这里专注VBA, 授人以渔。我98年开始,从源码接触VBA已经20余年了,随着年龄的增长,越来越觉得有必要把这项技能传递给需要这项技术的职场人员。希望职场和数据打交道的朋友,都来学习VBA,利用VBA,起码可以提高自己的工作效率,可以有时间多陪陪父母,多陪陪家人,何乐而不为呢?我的教程一共九套,从入门开始一直讲到程序的分发,是学习利用VBA的实用教程。这份API资料是随高级教程赠送的.

这讲我们继续学习64位Office API声明语句第116讲,这些内容是MS的权威资料,看似枯燥,但对于想学习API函数的朋友是非常有用的。

【分享成果,随喜正能量】 在这个喧嚣的世界里,我们常常忘记停下来享受生活的美好,忘记感受自然的力量和温暖。生火喝茶,是一种让我们回归内心、重新寻找平静的方式。无论是在清晨、午后还是夜晚,都可以享受这份宁静和舒适。 。

当学员学习到高级阶段,如果引用API,这个资料可以直接查到64位写法。大多数情况下我们是将低版本的程序文件升级到高版本,这时您就不必为如下的错误提示所困扰了:

Const OFN_PATHMUSTEXIST = &H800

Const OFN_FILEMUSTEXIST = &H1000

Const OFN_CREATEPROMPT = &H2000

Const OFN_SHAREAWARE = &H4000

Const OFN_NOREADONLYRETURN = &H8000&

Const OFN_NOTESTFILECREATE = &H10000

Const OFN_NONETWORKBUTTON = &H20000

Const OFN_NOLONGNAMES = &H40000 ' force no long names for 4.x modules

Const OFN_EXPLORER = &H80000 ' new look commdlg

Const OFN_NODEREFERENCELINKS = &H100000

Const OFN_LONGNAMES = &H200000 ' force long names for 3.x modules

Const OFN_SHAREFALLTHROUGH = 2

Const OFN_SHARENOWARN = 1

Const OFN_SHAREWARN = 0

Type NMHDR

hwndFrom As LongPtr

idfrom As LongPtr

code As Long

End Type

Type OFNOTIFY

hdr As NMHDR

lpOFN As OPENFILENAME

pszFile As String ' May be NULL

End Type

Const CDM_FIRST = (WM_USER + 100)

Const CDM_LAST = (WM_USER + 200)

Const CDM_GETSPEC = (CDM_FIRST + &H0)

Const CDM_GETFILEPATH = (CDM_FIRST + &H1)

Const CDM_GETFOLDERPATH = (CDM_FIRST + &H2)

Const CDM_GETFOLDERIDLIST = (CDM_FIRST + &H3)

Const CDM_SETCONTROLTEXT = (CDM_FIRST + &H4)

Const CDM_HIDECONTROL = (CDM_FIRST + &H5)

Const CDM_SETDEFEXT = (CDM_FIRST + &H6)

Type CHOOSECOLOR

lStructSize As Long

hwndOwner As LongPtr

hInstance As LongPtr

rgbResult As Long

lpCustColors As LongPtr

flags As Long

lCustData As LongPtr

lpfnHook As LongPtr

lpTemplateName As String

End Type

Declare PtrSafe Function ChooseColor Lib "comdlg32.dll" Alias "ChooseColorA" (pChoosecolor As CHOOSECOLOR) As Long

Const CC_RGBINIT = &H1

Const CC_FULLOPEN = &H2

Const CC_PREVENTFULLOPEN = &H4

Const CC_SHOWHELP = &H8

Const CC_ENABLEHOOK = &H10

Const CC_ENABLETEMPLATE = &H20

Const CC_ENABLETEMPLATEHANDLE = &H40

Const CC_SOLIDCOLOR = &H80

Const CC_ANYCOLOR = &H100

Type FINDREPLACE

lStructSize As Long ' size of this struct 0x20

hwndOwner As LongPtr ' handle to owner's window

hInstance As LongPtr ' instance handle of.EXE that

' contains cust. dlg. template

flags As Long ' one or more of the FR_??

lpstrFindWhat As String ' ptr. to search string

lpstrReplaceWith As String ' ptr. to replace string

wFindWhatLen As Integer ' size of find buffer

wReplaceWithLen As Integer ' size of replace buffer

lCustData As LongPtr ' data passed to hook fn.

lpfnHook As LongPtr ' ptr. to hook fn. or NULL

lpTemplateName As String ' custom template name

End Type

Const FR_DOWN = &H1

Const FR_WHOLEWORD = &H2

Const FR_MATCHCASE = &H4

Const FR_FINDNEXT = &H8

Const FR_REPLACE = &H10

Const FR_REPLACEALL = &H20

Const FR_DIALOGTERM = &H40

Const FR_SHOWHELP = &H80

Const FR_ENABLEHOOK = &H100

Const FR_ENABLETEMPLATE = &H200

Const FR_NOUPDOWN = &H400

Const FR_NOMATCHCASE = &H800

Const FR_NOWHOLEWORD = &H1000

Const FR_ENABLETEMPLATEHANDLE = &H2000

Const FR_HIDEUPDOWN = &H4000

Const FR_HIDEMATCHCASE = &H8000&

Const FR_HIDEWHOLEWORD = &H10000

Declare PtrSafe Function FindText Lib "comdlg32.dll" Alias "FindTextA " (pFindreplace As FINDREPLACE) As LongPtr

Declare PtrSafe Function ReplaceText Lib "comdlg32.dll" Alias "ReplaceTextA" (pFindreplace As FINDREPLACE) As LongPtr

Type CHOOSEFONT

lStructSize As Long

hwndOwner As LongPtr ' caller's window handle

hdc As LongPtr ' printer DC/IC or NULL

lpLogFont As LongPtr ' ptr. to a LOGFONT struct

iPointSize As Long ' 10 * size in points of selected font

flags As Long ' enum. type flags

rgbColors As Long ' returned text color

lCustData As LongPtr ' data passed to hook fn.

lpfnHook As LongPtr ' ptr. to hook function

lpTemplateName As String ' custom template name

hInstance As LongPtr ' instance handle of.EXE that

' contains cust. dlg. template

lpszStyle As String ' return the style field here

' must be LF_FACESIZE or bigger

nFontType As Integer ' same value reported to the EnumFonts

' call back with the extra FONTTYPE_

' bits added

MISSING_ALIGNMENT As Integer

nSizeMin As Long ' minimum pt size allowed &

nSizeMax As Long ' max pt size allowed if

' CF_LIMITSIZE is used

End Type

Declare PtrSafe Function ChooseFont Lib "comdlg32.dll" Alias "ChooseFontA" (pChoosefont As CHOOSEFONT) As Long

Const CF_SCREENFONTS = &H1

Const CF_PRINTERFONTS = &H2

Const CF_BOTH = (CF_SCREENFONTS Or CF_PRINTERFONTS)

Const CF_SHOWHELP = &H4&

Const CF_ENABLEHOOK = &H8&

Const CF_ENABLETEMPLATE = &H10&

Const CF_ENABLETEMPLATEHANDLE = &H20&

Const CF_INITTOLOGFONTSTRUCT = &H40&

Const CF_USESTYLE = &H80&

Const CF_EFFECTS = &H100&

Const CF_APPLY = &H200&

Const CF_ANSIONLY = &H400&

Const CF_SCRIPTSONLY = CF_ANSIONLY

Const CF_NOVECTORFONTS = &H800&

Const CF_NOOEMFONTS = CF_NOVECTORFONTS

Const CF_NOSIMULATIONS = &H1000&

Const CF_LIMITSIZE = &H2000&

Const CF_FIXEDPITCHONLY = &H4000&

Const CF_WYSIWYG = &H8000& ' must also have CF_SCREENFONTS CF_PRINTERFONTS

Const CF_FORCEFONTEXIST = &H10000

Const CF_SCALABLEONLY = &H20000

Const CF_TTONLY = &H40000

Const CF_NOFACESEL = &H80000

Const CF_NOSTYLESEL = &H100000

Const CF_NOSIZESEL = &H200000

Const CF_SELECTSCRIPT = &H400000

Const CF_NOSCRIPTSEL = &H800000

Const CF_NOVERTFONTS = &H1000000

Const SIMULATED_FONTTYPE = &H8000

Const PRINTER_FONTTYPE = &H4000

Const SCREEN_FONTTYPE = &H2000

Const BOLD_FONTTYPE = &H100

Const ITALIC_FONTTYPE = &H200

Const REGULAR_FONTTYPE = &H400

Const WM_CHOOSEFONT_GETLOGFONT = (WM_USER + 1)

Const WM_CHOOSEFONT_SETLOGFONT = (WM_USER + 101)

Const WM_CHOOSEFONT_SETFLAGS = (WM_USER + 102)

Const LBSELCHSTRING = "commdlg_LBSelChangedNotify"

我20多年的VBA实践经验,全部浓缩在下面的各个教程中:

0 阅读:2