+ Reply to Thread
Results 1 to 6 of 6

UserForm Issue

Hybrid View

Guest UserForm Issue 08-10-2006, 09:05 AM
Guest Re: UserForm Issue 08-10-2006, 09:10 AM
Guest RE: UserForm Issue 08-10-2006, 09:35 AM
Guest RE: UserForm Issue 08-10-2006, 09:40 AM
Guest Re: UserForm Issue 08-10-2006, 09:50 AM
Guest Re: UserForm Issue 08-10-2006, 09:45 AM
  1. #1
    Tom Ogilvy
    Guest

    RE: UserForm Issue

    Just some added info:
    Here is some sample code from Rob Bovey:



    UserForms in an Excel project are private classes, so you can't call
    a UserForm in another project directly. What you can do is create a public
    function in the other project that returns an object reference to the
    UserForm. You will then be able to control the UserForm with this object
    reference from the outside project.


    For instance, if you have a UserForm named frmMyForm in the workbook
    Server.xls, you can add the following function to a regular module in that
    workbook to expose the UserForm


    Function ReturnForm() As frmMyForm
    Set ReturnForm = New frmMyForm
    End Function


    Then you can show this UserForm from a different procedure like so:


    Sub ShowForm()
    Dim objForm As Object
    Set objForm = Application.Run("Server.xls!ReturnForm")
    objForm.Show
    End Sub



    Rob Bovey

    --
    Regards,
    Tom Ogilvy


    "Thomas" wrote:

    > Hi,
    >
    > I am opening an excel spreadsheet with a userform from another application
    > (see code below) using late binding. I need to populate controls with data.
    > How do I reference the userform?
    >
    > Set objExcel = CreateObject("Excel.Application")
    > Set wbExcel = objExcel.Workbooks.Open("C:\test.xls")
    >
    > I tried wbExcel.UserForm11.TextBox1.Text and it does not work. Any ideas?
    >
    > Thanks
    >
    >
    >


  2. #2
    Thomas
    Guest

    Re: UserForm Issue

    Thanks for the post. After posting I figured out that I could build a
    public method in the workbook that I can pass data and that method interact
    with the userform.


    "Tom Ogilvy" <TomOgilvy@discussions.microsoft.com> wrote in message
    news:45EF0D0C-9582-409A-9786-7B07216F922A@microsoft.com...
    > Just some added info:
    > Here is some sample code from Rob Bovey:
    >
    >
    >
    > UserForms in an Excel project are private classes, so you can't call
    > a UserForm in another project directly. What you can do is create a public
    > function in the other project that returns an object reference to the
    > UserForm. You will then be able to control the UserForm with this object
    > reference from the outside project.
    >
    >
    > For instance, if you have a UserForm named frmMyForm in the workbook
    > Server.xls, you can add the following function to a regular module in that
    > workbook to expose the UserForm
    >
    >
    > Function ReturnForm() As frmMyForm
    > Set ReturnForm = New frmMyForm
    > End Function
    >
    >
    > Then you can show this UserForm from a different procedure like so:
    >
    >
    > Sub ShowForm()
    > Dim objForm As Object
    > Set objForm = Application.Run("Server.xls!ReturnForm")
    > objForm.Show
    > End Sub
    >
    >
    >
    > Rob Bovey
    >
    > --
    > Regards,
    > Tom Ogilvy
    >
    >
    > "Thomas" wrote:
    >
    >> Hi,
    >>
    >> I am opening an excel spreadsheet with a userform from another
    >> application
    >> (see code below) using late binding. I need to populate controls with
    >> data.
    >> How do I reference the userform?
    >>
    >> Set objExcel = CreateObject("Excel.Application")
    >> Set wbExcel = objExcel.Workbooks.Open("C:\test.xls")
    >>
    >> I tried wbExcel.UserForm11.TextBox1.Text and it does not work. Any
    >> ideas?
    >>
    >> Thanks
    >>
    >>
    >>




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1