Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

How do I copy macro button from one workbook to another?

I need to copy Sheet1 in Mail.xlsm (attached) to another workbook OtherWorkbook.xlsm. My copy procedure is this - with both workbooks open, I go into Developer/Visual Basic and drag the module/macro from Mail.xlsm to OtherWorkbook.xlsm. I then copy Sheet1 from Mail.xlsm to OtherWorkbook.xlsm.

When I click the button/macro in Sheet1 of OtherWorkbook.xlsm the result is - Compile error: User-defined type not defined. Also, underlying code is displayed with Public Sub CreateAnEmail() highlighted in yellow and the lineDim objOutlook As Outlook.Application highlighted in blue.
Mail.xlsm
0
K_Deutsch
Asked:
K_Deutsch
1 Solution
 
als315Commented:
References to additional libraries are not inserted automatically.
After copy you should open (in VBA editor) Tools-References from menu and add reference to proper Outlook library (in my case Microsoft Outlook 14.0):
library
0
 
K_DeutschAuthor Commented:
Works. Thanks for the tip.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now