473,378 Members | 1,482 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

EXCEL - accessing workbook.A.userform from workbook.B

pod
298 100+
Hello

What I want to do is:
from this workbook (thisWB), I want to access a userform's properties that are in another Workbook (toolWB)

I can do this for worksheets, but I want to do it as well for the userform

I have searched the help files, forums and went through all of the properties of workbooks and worksheets to no avail.

I have a way to go around my problem but not without rewriting a lot of code.

If someone has any ideas on the subject, please let me know.

Expand|Select|Wrap|Line Numbers
  1. Option Explicit ' this code is on a thisWB module
  2. Public toolWB As Workbook
  3. Public deskSHEET As Worksheet
  4. Public deskFRM As UserForm
  5. Sub setToolWB()
  6.     Set toolWB = toolWB
  7.     Set deskSHEET = toolWB.Sheets("Desk Bureau") ' this works
  8.     Set deskFRM = toolWB.[???]         ' HELP!
  9. End Sub
Thanks


P :oD
Nov 20 '09 #1

✓ answered by ADezii

@pod
It wasn't easy, but I figured out a Method to programmatically access/set the Properties of a UserForm contained within the same Workbook as the code execution. It may not be the easiest partial solution, but it does work. It should not be a hugh leap to use this logic with an External Workbook. First a few pointers:
  1. Tools
  2. Macro
  3. Security
  4. Trusted Publishers Tab
  5. Select ==> Trust access to Visual basic Project
Expand|Select|Wrap|Line Numbers
  1. Dim VBC As Object      'UserForm VBComponent
  2. Set VBC = Workbooks("Book1.xls").VBProject.VBComponents("UserForm1")
  3.  
  4. VBC.Designer.Controls("Label1").Caption = "Help me Rhonda, please!"

3 11406
Dököll
2,364 Expert 2GB
Hey there pod!

Good job posting a sample code... Sending over to the Access forum for looks.

Good luck with this project, in a bit!
Nov 21 '09 #2
ADezii
8,834 Expert 8TB
@pod
It wasn't easy, but I figured out a Method to programmatically access/set the Properties of a UserForm contained within the same Workbook as the code execution. It may not be the easiest partial solution, but it does work. It should not be a hugh leap to use this logic with an External Workbook. First a few pointers:
  1. Tools
  2. Macro
  3. Security
  4. Trusted Publishers Tab
  5. Select ==> Trust access to Visual basic Project
Expand|Select|Wrap|Line Numbers
  1. Dim VBC As Object      'UserForm VBComponent
  2. Set VBC = Workbooks("Book1.xls").VBProject.VBComponents("UserForm1")
  3.  
  4. VBC.Designer.Controls("Label1").Caption = "Help me Rhonda, please!"
Nov 22 '09 #3
pod
298 100+
Thanks ADezii for pointing me in the right direction. I am not out of the woods yet, I am having a hard time now displaying the Userform, not to mention setting the rowsource to list controls on the form.
But I just found a good Web Reference on "VBProject.VBComponents" @http://www.cpearson.com/excel/vbe.aspx

P:oD
Nov 23 '09 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mike Eaton | last post by:
Hi there, I'm working on an application that opens an excel workbook, does some processing on the data contained in it, and then saves the data into the workbook. What I'm noticing is that once...
1
by: Lucile | last post by:
Hi all, I am trying to open a Excel Workbook to check data in worksheets. The ONLY info I have about the EXCEL file is its entire path. I tried to do the following, but an exception occurs: ...
1
by: garry.oxnard | last post by:
Can anyone help me to solve a problem which involves switching from Access to Excel (then back to Access) programatically please? I have an Excel template which, on open, also opens an Access...
0
by: ketz | last post by:
How do i create a user login for a excel spreadsheet through a userform. I've seem to be able to get a password working but that only lets one passwrod in and its only the password. Ideally what i'd...
0
by: sradoff | last post by:
I wish to use XPath to access data from within an Excel generated XML Spreadsheet (generated with MS Excel 2003). I am using an asp Web page (not .NET, not at this time). I instantiate...
6
by: William Foster | last post by:
Good morning all, I want to password protect a Microsoft Excel Workbook containing all my reference tables for a program, so that I can place the workbook in a central location that is...
2
by: Nicholas Dreyer | last post by:
The following error Run-time exception thrown : System.Runtime.InteropServices.COMException - Error loading type library/DLL. happens while running the code listed at the bottom of this...
3
by: mforema | last post by:
Hello, I have a userform in Excel with a textbox and cmd button. I want to give the user the ability to search for a specific worksheet name within an Excel Workbook. My code for the cmd button...
16
emibt08
by: emibt08 | last post by:
Hello fellow programmers. I am working on a project that is a windows service. It should open an excel file and read it and it worked good on WinXP SP2 w/ Office 2003. Now the customer upgraded to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.