Accessing UserForm In WorkBook (A) From WorkBook (B)

Jan 2, 2013

there is no direct method to access the Properties/Methods of a remote userform and its controls at runtime..... I needed this in a small project recently and I thought I would post here the solution I came up with as this may prove useful to others.

1- Code in the UserForm Module in Workbook A (Server workbook)

Code:
Option Explicit
Private Declare Function SetProp Lib "user32" Alias "SetPropA" _
(ByVal hwnd As Long, ByVal lpString As String, ByVal hData As Long) As Long
Private Declare Function RemoveProp Lib "user32" Alias "RemovePropA" _
(ByVal hwnd As Long, ByVal lpString As String) As Long

[code]....

This also works for more than one loaded userform.

View 1 Replies


ADVERTISEMENT

Excel 2010 :: Accessing VBA Module From UserForm On Workbook Open

Feb 13, 2013

I am using Excel 2010 and late binding to generate reports. The sheets are blank and unused. I have the UserForm being opened on Workbook_Open and the actual VBA for doing the work in a separate macro in the workbook. All the posts I have found are dealing with accessing cells from the UserForm and I haven't found any dealing with connecting a macro to the UserForm output.

My question is this: I want to return from the UserForm the flags of which reports to run to the (unopened) macro containing the code to do so. How do I open the macro and pass the variables to it?

The UserForm is creatively called "SelectionForm" and the macro is called "DailyFTP" with a Main sub as the entry. I know I can use the code under to capture the radio button and checkbox choices. I have other variables like the names of files set as global variables in the DailyFTP macro. The macro doesn't exist until SelectionForm opens it, so they must be set after the macro is in memory.

View 6 Replies View Related

Accessing Data From Other Workbook

Jan 17, 2008

How can i access data from other workbook i have opened.?
I am new in VBA.So little code snippet would be good to show.
I want to get the cell data from workbook2 to workbook1

View 9 Replies View Related

Prevent Workbook Being Left Open Stopping Others Accessing

Feb 20, 2008

I have a spreadsheet on an intranet drive, and many people need to see it and enter information. Sometimes, we have the file opened on a computer, and the user walks away, and their station is locked. That prevents anyone from updating or using the file! locate a macro that will count how long the file is inactive, and then quit?
I'm not at all comfortable coding in VBA, and this sort of thing is out of my range!

View 4 Replies View Related

Userform VBA - VLookup Data Range From One Workbook And Populate Into Another Workbook

Feb 9, 2013

what VBA is required to have a combo box in a userform look up data in a different workbook, then populate that data into the drop down list of that combo box for a user to select.

I have managed to successfully create a vlookup for a combo box in a userform that looks up data in a named range in another worksheet within the same workbook and then populate that data into a field in a worksheet within the same workbook. However, I want to change this so the combo box on a userform (in one workbook) will look up data from a named range in a second workbook without opening the second workbook. At the moment, the code I have that will 'submit' the user selected data from the combo box drop down list works.

The code that has worked so far to vlookup data for the combo box from a worksheet within the same workbook is:

Code:
Private Sub UserForm_Initialize()
Dim pName As Range
Dim ws As WorksheetSet ws = Worksheets("vlookupsheet")
For Each pName In ws.Range("ProjectName")
With Me.cboProjectName
.AddItem pName.Value
End WithNext pName
Me.cboProjectName.SetFocus
End Sub

Do I need specify the file path of the second workbook that will contain the data for the combo box as well as the name of the worksheet and named range in that second workbook?

View 4 Replies View Related

Copying Data From Userform To Another Workbook Without Opening Second Workbook

May 16, 2014

I have created userform and it works fine. Following code assigned to 'SUBMIT' button in userform - works fine. I am trying to include code where certain data from userform is also copied to workbook2 ( of course without opening it)- as marked in red...below

[Code].....

View 4 Replies View Related

Open Workbook Via Another Workbook And Not Display Userform

Mar 3, 2009

I have a workbook ("Time") that when opened displays a userform. I also have another workbook ("Master") that opens the "Time" workbook to retrieve information. Is there a way to use the Master workbook to open the Time workbook WITHOUT displaying the userform.

View 2 Replies View Related

Open 2nd Workbook From Userform Then Close 2nd Userform?

Jul 4, 2012

What I would like to do is to be able to open a second workbook from a user form, preform some work on it then save and come back to the same place in the original user form.

So in steps:

1 : user clicks command button to open user form
2: user then clicks on command button on userform that opens 2nd workbook via a yes / no message box, but closes userform on 1st workbook (would be ideal if this could stay open, but hidden)
3: user then does work on 2nd workbook,
4: userform on 2nd workbook saves then activates the 1st workbook and reopens the userform

This is where no matter what I try I cant get the command button on the 1st userform to be clicked automatically so the yes / no message box appears.

This is part of the code in the 2nd sheet commandbutton that saves / closes / opens

Code:
Unload Me
ActiveWorkbook.save
Windows("ABC.xlsm").Activate
Sheets("Request Sheet").Activate
Call Sheets("Request Sheet").ForceClickOnBouttonXYZ
Call UserForm1.CommandButton6_Click 'this is where I cant get it to work!!
Windows("xyz.xlsm").Close
ABC is the 1st workbook
xyz is the 2nd workbook

This is the code on the 1st workbook I use to call on the 2nd workbook

Code:
Public Sub ForceClickOnBouttonXYZ() Call CommandButton1_Click End Sub

View 7 Replies View Related

Userform Will Not Save Workbook?

Jan 4, 2013

I have a userform where data is entered and upon pressing submit it saves the workbook. this has been working fine, but all of a sudden today it has stopped saving.

I have tried using ThisWorkbook.Save and Activeworkbook.save and both appear to save (i see the "saving" dialogue box), the data is submitted into the spreadsheet behind the userform. But as soon as i close and re-open it, the data isnt there.

I assumed it may be some sort of permissions issue where the file is located. But if i manually enter the data into the spreadsheet and press save, it works and retains the data! So it appears to be something wrong with my userform, which has magically happened over night.

View 2 Replies View Related

From Userform / Other Workbook Not Closing

Nov 26, 2013

I wrote this macro where, from a userform, I click a button and it will fillout another form with certain data from the original WB to a different WB.

All is working fine and exactly the way I want it except, it won't close and save the other sheet. It will go back to the userform, as I want it to, but it will leave the other file in the background open.

This is the code:

Code:
Private Sub CommandButton6_Click()
'Allocation file fill out
Dim alloc As String
Dim allwb As Workbook
Dim ABA As Workbook
Dim Prompt As String
'Dim fd As FileDialog
Set ABA = ThisWorkbook

[code]....

View 2 Replies View Related

Deleting A Workbook From A Userform Vba

Feb 13, 2007

How is it possible to delete a workbook from a userform in an open workbook?

View 6 Replies View Related

Opening A Workbook With A Userform...

Apr 2, 2007

I've created a simple userform with buttons that perform certain macros.

1. how do i make the userform to pop up every time the workbook is open?

2. i got the userform to pop up via macros menu.. but the buttons doesnt seem to work... could you guys give quick lesson on how to add a macro command to a button on userform?

View 2 Replies View Related

Copy A Userform From One Workbook Into Another

May 19, 2007

how to copy a userform from one workbook into another. I can't find anything on this site

View 4 Replies View Related

Show Userform On Workbook Open

Dec 7, 2009

This is the code I received for showing a userform upon open...but it's not working.

View 10 Replies View Related

Saving Userform Data To Different Workbook?

Oct 29, 2009

Is it possible to have a userform open in a workbook and when the data from the form is saved, save it to a completely different workbook. If so, will that other workbook need to be open for the userform data to be saved?

View 5 Replies View Related

Copying From Userform Into Table On Another Workbook

Nov 17, 2008

I am trying to get a userform/database thing going,

basically, user types in a series of textboxes and hits a "submit" button.
That submit button would copy the values to a recipient table.

How do I get things to copy across workbooks?

View 4 Replies View Related

Saving Userform Data To Different Workbook

Oct 29, 2009

Is it possible to have a userform open in a workbook and when the data from the form is saved, save it to a completely different workbook. If so, will that other workbook need to be open for the userform data to be saved?

View 4 Replies View Related

Hide A UserForm On Workbook Deactivation

Nov 16, 2009

I often have several workbooks open and shift from one to another. One of these contains a floating UserForm; and the trouble is that when I leave this workbook and shift to another one, the UserForm belonging to the first remains open and visible in the new workbook; and I cannot hide this nuisance. Within the same workbook, it’s easy to hide the Useform when shifting to another worksheet (through code for Private Sub Worksheet_Deactivate()). Is there something similar for when the whole workbook is deactivated?

View 4 Replies View Related

Copying Info From Userform To New Workbook

Aug 6, 2012

I have written this code and so far all works accept for this bit where I want to add the required data to cells 3,2....nothing happens, no errors, it just doesn't do anything.

Private Sub CommandButton1_Click()
Dim wbo As Workbook
Dim wbn As Workbook
Dim wso As Worksheet
Dim wsn As Worksheet

[Code]....

View 7 Replies View Related

Hiding Workbook While Showing UserForm

Jun 12, 2013

1. I'm looking for a better way to get a UserForm (frmParts) to show right from the start as soon as I open the workbook while hiding the application. I use the following when I initialize the application:

Code:
Application.Visible = False
frmParts.Show

2. Later on, I add some parts to my inventory, but if I don't make the application visible, it doesn't save the data. So, I have to make it visible and then hide it again. Is there a right way to accomplish the save without having to unhide/hide the application? This is the applicable code I used (ComboBoxes & TextBoxes involved):

Code:
'copy the data to the database
Application.Visible = True
Application.ScreenUpdating = False

With ws 'ws=Inventory

[Code] ..........

View 1 Replies View Related

Working With Workbook While Userform Is Running

Mar 12, 2014

is there any way to work with excel workbook while in another excel workbook userform is running

View 1 Replies View Related

Get UserForm Names From A Seperate Workbook

Mar 6, 2006

I'm working to develop a method to programmatically identify the type of object contained in a UserForm, it's relevant property(s) & their current values.

Currently, I'm importing the relevant form into a new form module within the VBA Project. I'd like to be able to set the Workbook & Userform as variables within the code & do away with the import step. It appears the target workbook can be addressed by using the statement,

Set my_Workbook = CreateObject(Application. GetOpenFilename)

However I'm coming unstuck with the correct syntax to address UserForms in another workbook.

View 6 Replies View Related

Minimize Workbook On Userform Launch

Oct 24, 2006

Is there a way to minimize Excel when a userform is launched, so just the userform is showing? I've tried using "Application.WindowState = xlMinimized" in the UserForm initialization procedure, but it minimizes both the workbook/application and the UserForm. I can click on the Excel window on the taskbar and just the UserForm will display--which is the goal--but I'm hoping there's a way to do it automatically without needing to click the taskbar icon after it's minimized.

View 2 Replies View Related

Open Workbook Window On Top Of UserForm

Mar 13, 2008

I have a userform with several buttons on, each doing seperate tasks, three of the buttons however are used to load a workbook stored elsewhere in our central data storage drive. Loading these workbooks is not the problem, the problem is when loading these they load up behind the userform and not in a new window.

View 6 Replies View Related

Macro To Edit Userform In Other Workbook

Apr 23, 2008

I'm writing a macro that opens another Excel file, opens a userform within that file, and manipulates the data. I've never tried to do this before. I keep getting "Object Required" error. My macro fails on the "frmMain.Show" where "frmMain" is the userform I am interested in. Here's the


Excel.Application.Workbooks.Open ("C:DataCalculations.xls") 'Open file
frmMain.Show 'Bring-up UserForm
frmMain.cbUser.Value = "Guest" 'Sign as Guest
frmMain.cbVariables.Value = var 'number of variables

View 3 Replies View Related

Hide Userform When Opening Another Workbook

Aug 7, 2008

I have a userform on a worksheet. Now, I open anothe workbook, the userform still stays on top of all the workbooks. However, if I open a new workbook(new instance of excel), then it does not show. I need the userform to be a part of the excel which I open. not for all workbooks.

Few comments before I complete: This was working as intended. All of a sudden, I messed up with the code and it burnt out. Secondly, the ShowModel of userform is set to False as I need to hide the workbook when userform opens. Hence, I cannot set that to true.

View 3 Replies View Related

Populate Userform Combobox From Range In Different Workbook

Jul 28, 2012

I am looking to fill out a combobox (say combobox1) in a userform from a set of ranges located in a different workbook (that is in a different location).

For example, the cells that would need to be in the combobox are B5:B41,D5:D40 and F5:F45 and the file location is W:WCWORKCENTERS.xls

View 3 Replies View Related

Userform As Printer Interface For Protected Workbook

Apr 21, 2014

I'm closing in on the final stage of a large project and I've run into a road block. The following line of code is preventing my users from being able to select specific page ranges when using the Print Entire Workbook option in the print menu.

[Code] .....

I've attached the latest version of my form (with significant support by jaslake) to explain what I'm attempting here. The attached form has several macros that activate upon open; including a user form. The password for the workbook/worksheets/VBE is "j".

Attached File : HCT-RCS ITP V1.89.xlsm

View 14 Replies View Related

How To Show Userform Hiding Specific Workbook

May 19, 2014

I need a code (and where to put it) to open my application excel with only the userform so, with the workbook hidden.

Application.Visible=False doesn't work because it close all excels and moreover I can see the workbook for 1 or 2 seconds before hiding.

View 1 Replies View Related

Userform Called In Other Workbook Interrupts Procedure

Aug 22, 2014

I have a procedure that opens workbooks from a list and then searchs for a phrase given by user. If nothing is found it closes workbook and opens next one. If phrase is found it highlights it on workbook. I wanted to give user some options when phrase is found: to search further in next workbook and to search further, but leaving current workbook open. Here my misery starts.

The only way i made up to perform it was to use Userform and code: userform.ActiveControl.Name. But it seems that Userform called in other workbook than one where the module is, interrupts somehow the procedure. When workbook, where the userform was used, closes the procedure doesn't go on. Evidently Userform is the issue here as without it, macro works.

See my code below :

[Code] .........

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved