
Function based constraints or domains provide the advantage of instant increase of the length constraint, and on the basis that decreasing a string length constraint is rare, depesz concludes that one of them is usually the best choice for a length limit. It also takes a detailed look at alternate ways on constraining the length when needed. The article does detailed testing to show that the performance of inserts and selects for all 4 data types are similar.


The advantage of the API becomes apparent when checking for windows that other applications have opened. With both, application name and window caption, known code like this can be written:-Ĭode: Select all If FindWindow("XLMAIN", "Microsoft Excel - My Workbook") ThenĮnd IfThis capability is of little, if any, use while programming for any one Office application because each one supplies its own code to check if a specific file is open. The API GetWindowText isn't supplied in this thread but would have to be adapted to the available VBA version as well. While this code is backward compatible to Excel 2003 the API FindWindow published above needs to be made pointer safe to run on 64-bit Excel 2010.

WinHandle = FindWindow("XLMAIN", vbNullString) ' Get the handle needed by GetWindowTextĬall GetWindowText(WinHandle, WinTitle, 260)ĭebug.Print WinTitle ' Print the Window caption In the above situation, where the window's application name was known, the window's caption can be returned by the API GetWindowText as is demonstrated with the following code (written for 64-bit VBA7):-Ĭode: Select all Private Sub GetWindowCaption() Microsoft Excel - My WorkbookThe above API function will return the window's handle if the window's caption is supplied correctly.
