Referencing other files from an addin

If your add-in uses other files, you need to be especially careful when distributing the application. You can't assume anything about the storage structure of the system that users will run the application on. The easiest approach is to insist that all files for the application be copied to a single directory. Then you can use the Path property of your application's workbook to build path references to all other files.

For example, if your application uses a custom help file, be sure that the help file is copied to the same directory as the application itself. Then you can use a procedure like the following to make sure that the help file can be located:

Sub GetHelp()

Dim Path As String Path = ThisWorkbook.Path Application.Help Path & "\USER.CHM" End Sub

If your application uses Application Programming Interface (API) calls to standard Windows DLLs, you can assume that these can be found by Windows. But if you use custom DLLs, the best practice is to make sure that they're installed in the Windows\System directory (which might or might not be named Windows\System). You'll need to use the GetSystemDirectory Windows API function to determine the exact path of the System directory.

0 0

Post a comment