?
Solved

Excel VBA: Finding workbook form belongs to

Posted on 2012-04-11
1
Medium Priority
?
322 Views
Last Modified: 2012-04-11
What VBA code would I need so that when a form in Excel opens, the workbook the form belongs to is stored in a public variable.

e.g., Whenever "ctrl+Y" is pressed the form opens. Therefore if the user is on another workbook and presses "ctrl-y" I would like the form to log the workbook the form belongs to, NOT THE CURRENT workbook.

e.g., putting "activeworkbook.name" in the "On Form Open" sub would not work in this case, as the form could be opened while the user is on another workbook in such case would yield incorrect results.
0
Comment
Question by:ouestque
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 24

Accepted Solution

by:
StephenJR earned 2000 total points
ID: 37832599
You can use ThisWorkbook to refer to the book containing code.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question