Sharing VBA modules across MS Office Applications

后端 未结 4 1573
野趣味
野趣味 2021-01-22 08:29

I have a substantial bank of VBA modules written in an Excel 2010 add-in. Some of these are specific to Excel, but many are more general. For example one takes a part number an

4条回答
  •  失恋的感觉
    2021-01-22 09:00

    Maybe can help somebody.

    My solution has been set conditional compiler arguments in project properties:

    • In excel project: SOFT_EXCEL = 1 : SOFT_OUTLOOK = 0

    • In outlook project: SOFT_EXCEL = 0 : SOFT_OUTLOOK = 1

    Then, in module:

    Public Sub as_email()
        #If SOFT_EXCEL Then
            Debug.Print "this executes and compiles in excel"
        #End If
        #If SOFT_OUTLOOK Then
            Debug.Print "this executes and compiles in outlook"
        #End If
    End Sub
    

提交回复
热议问题