+ Reply to Thread
Results 1 to 8 of 8

Early and Late Binding Vba Excel

  1. #1
    VJ
    Guest

    Early and Late Binding Vba Excel

    Does any one help me why I can't refer to the form with this method in VBA
    Excel.

    dim var_sr_form_name as object
    Set var_sr_form_name = ActiveWorkbook.VBProject.VBComponents("formName")

    I get error when I use

    var_sr_form_name.show method to show the form

    or try to access any component of the form.

    Thanks in advance for ur help.

    VJ

  2. #2
    Chip Pearson
    Guest

    Re: Early and Late Binding Vba Excel

    Your code works fine for me. Exactly what problem do you
    encounter?


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "VJ" <[email protected]> wrote in message
    news:[email protected]...
    > Does any one help me why I can't refer to the form with this
    > method in VBA
    > Excel.
    >
    > dim var_sr_form_name as object
    > Set var_sr_form_name =
    > ActiveWorkbook.VBProject.VBComponents("formName")
    >
    > I get error when I use
    >
    > var_sr_form_name.show method to show the form
    >
    > or try to access any component of the form.
    >
    > Thanks in advance for ur help.
    >
    > VJ




  3. #3
    VJ
    Guest

    Re: Early and Late Binding Vba Excel

    I have four forms: form1, form2, form3 and form4

    when click on cmdbtn on form1, form2 shows up and in the initialize event of
    the form2 I am getting reference to either form3 or form4 depending upon the
    logic. the name of the form4 is dynamic because I am importing the form4 from
    another workbook.

    I get the err in the initialize event of form2 where after getting reference
    to form3 or form4 I use varName.show.

    The varName referes to either form3 or form4 through binding.

    Ur help would be appreciated.

    Thanks

    "Chip Pearson" wrote:

    > Your code works fine for me. Exactly what problem do you
    > encounter?
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    > "VJ" <[email protected]> wrote in message
    > news:[email protected]...
    > > Does any one help me why I can't refer to the form with this
    > > method in VBA
    > > Excel.
    > >
    > > dim var_sr_form_name as object
    > > Set var_sr_form_name =
    > > ActiveWorkbook.VBProject.VBComponents("formName")
    > >
    > > I get error when I use
    > >
    > > var_sr_form_name.show method to show the form
    > >
    > > or try to access any component of the form.
    > >
    > > Thanks in advance for ur help.
    > >
    > > VJ

    >
    >
    >


  4. #4
    VJ
    Guest

    Re: Early and Late Binding Vba Excel

    Hi Chip,

    It seems to me that

    ActiveWorkbook.VBProject.VBComponents("formName") doesnt calls the
    initialize event of the form.

    Thanks


    "VJ" wrote:

    > I have four forms: form1, form2, form3 and form4
    >
    > when click on cmdbtn on form1, form2 shows up and in the initialize event of
    > the form2 I am getting reference to either form3 or form4 depending upon the
    > logic. the name of the form4 is dynamic because I am importing the form4 from
    > another workbook.
    >
    > I get the err in the initialize event of form2 where after getting reference
    > to form3 or form4 I use varName.show.
    >
    > The varName referes to either form3 or form4 through binding.
    >
    > Ur help would be appreciated.
    >
    > Thanks
    >
    > "Chip Pearson" wrote:
    >
    > > Your code works fine for me. Exactly what problem do you
    > > encounter?
    > >
    > >
    > > --
    > > Cordially,
    > > Chip Pearson
    > > Microsoft MVP - Excel
    > > Pearson Software Consulting, LLC
    > > www.cpearson.com
    > >
    > >
    > > "VJ" <[email protected]> wrote in message
    > > news:[email protected]...
    > > > Does any one help me why I can't refer to the form with this
    > > > method in VBA
    > > > Excel.
    > > >
    > > > dim var_sr_form_name as object
    > > > Set var_sr_form_name =
    > > > ActiveWorkbook.VBProject.VBComponents("formName")
    > > >
    > > > I get error when I use
    > > >
    > > > var_sr_form_name.show method to show the form
    > > >
    > > > or try to access any component of the form.
    > > >
    > > > Thanks in advance for ur help.
    > > >
    > > > VJ

    > >
    > >
    > >


  5. #5
    Chip Pearson
    Guest

    Re: Early and Late Binding Vba Excel

    > ActiveWorkbook.VBProject.VBComponents("forename") doesn't calls
    > the
    > initialize event of the form.


    No it doesn't. Why would you think it would? From your earlier
    reply, it seems to me you don't need to use the VBProject object
    at all. What, exactly, are you trying to do?


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com


    "VJ" <[email protected]> wrote in message
    news:[email protected]...
    > Hi Chip,
    >
    > It seems to me that
    >
    > ActiveWorkbook.VBProject.VBComponents("formName") doesnt calls
    > the
    > initialize event of the form.
    >
    > Thanks
    >
    >
    > "VJ" wrote:
    >
    >> I have four forms: form1, form2, form3 and form4
    >>
    >> when click on cmdbtn on form1, form2 shows up and in the
    >> initialize event of
    >> the form2 I am getting reference to either form3 or form4
    >> depending upon the
    >> logic. the name of the form4 is dynamic because I am importing
    >> the form4 from
    >> another workbook.
    >>
    >> I get the err in the initialize event of form2 where after
    >> getting reference
    >> to form3 or form4 I use varName.show.
    >>
    >> The varName referes to either form3 or form4 through binding.
    >>
    >> Ur help would be appreciated.
    >>
    >> Thanks
    >>
    >> "Chip Pearson" wrote:
    >>
    >> > Your code works fine for me. Exactly what problem do you
    >> > encounter?
    >> >
    >> >
    >> > --
    >> > Cordially,
    >> > Chip Pearson
    >> > Microsoft MVP - Excel
    >> > Pearson Software Consulting, LLC
    >> > www.cpearson.com
    >> >
    >> >
    >> > "VJ" <[email protected]> wrote in message
    >> > news:[email protected]...
    >> > > Does any one help me why I can't refer to the form with
    >> > > this
    >> > > method in VBA
    >> > > Excel.
    >> > >
    >> > > dim var_sr_form_name as object
    >> > > Set var_sr_form_name =
    >> > > ActiveWorkbook.VBProject.VBComponents("formName")
    >> > >
    >> > > I get error when I use
    >> > >
    >> > > var_sr_form_name.show method to show the form
    >> > >
    >> > > or try to access any component of the form.
    >> > >
    >> > > Thanks in advance for ur help.
    >> > >
    >> > > VJ
    >> >
    >> >
    >> >




  6. #6
    VJ
    Guest

    Re: Early and Late Binding Vba Excel

    I need to get reference to one of the form in the workbook .

    So I loop through all the forms in the workbook and I get the reference to
    that form whose name starts with "frm_sr".

    So kindly tell me how I can refer to that form dynamically.

    Thanks



    "Chip Pearson" wrote:

    > > ActiveWorkbook.VBProject.VBComponents("forename") doesn't calls
    > > the
    > > initialize event of the form.

    >
    > No it doesn't. Why would you think it would? From your earlier
    > reply, it seems to me you don't need to use the VBProject object
    > at all. What, exactly, are you trying to do?
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    > "VJ" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi Chip,
    > >
    > > It seems to me that
    > >
    > > ActiveWorkbook.VBProject.VBComponents("formName") doesnt calls
    > > the
    > > initialize event of the form.
    > >
    > > Thanks
    > >
    > >
    > > "VJ" wrote:
    > >
    > >> I have four forms: form1, form2, form3 and form4
    > >>
    > >> when click on cmdbtn on form1, form2 shows up and in the
    > >> initialize event of
    > >> the form2 I am getting reference to either form3 or form4
    > >> depending upon the
    > >> logic. the name of the form4 is dynamic because I am importing
    > >> the form4 from
    > >> another workbook.
    > >>
    > >> I get the err in the initialize event of form2 where after
    > >> getting reference
    > >> to form3 or form4 I use varName.show.
    > >>
    > >> The varName referes to either form3 or form4 through binding.
    > >>
    > >> Ur help would be appreciated.
    > >>
    > >> Thanks
    > >>
    > >> "Chip Pearson" wrote:
    > >>
    > >> > Your code works fine for me. Exactly what problem do you
    > >> > encounter?
    > >> >
    > >> >
    > >> > --
    > >> > Cordially,
    > >> > Chip Pearson
    > >> > Microsoft MVP - Excel
    > >> > Pearson Software Consulting, LLC
    > >> > www.cpearson.com
    > >> >
    > >> >
    > >> > "VJ" <[email protected]> wrote in message
    > >> > news:[email protected]...
    > >> > > Does any one help me why I can't refer to the form with
    > >> > > this
    > >> > > method in VBA
    > >> > > Excel.
    > >> > >
    > >> > > dim var_sr_form_name as object
    > >> > > Set var_sr_form_name =
    > >> > > ActiveWorkbook.VBProject.VBComponents("formName")
    > >> > >
    > >> > > I get error when I use
    > >> > >
    > >> > > var_sr_form_name.show method to show the form
    > >> > >
    > >> > > or try to access any component of the form.
    > >> > >
    > >> > > Thanks in advance for ur help.
    > >> > >
    > >> > > VJ
    > >> >
    > >> >
    > >> >

    >
    >
    >


  7. #7
    Chip Pearson
    Guest

    Re: Early and Late Binding Vba Excel

    Try something like

    Dim FrmName As String
    Dim UF As Object
    FrmName = "Userform1"

    Set UF = VBA.UserForms.Add(FrmName)
    UF.Caption = "Hello, World"
    UF.Show


    --
    Cordially,
    Chip Pearson
    Microsoft MVP - Excel
    Pearson Software Consulting, LLC
    www.cpearson.com




    "VJ" <[email protected]> wrote in message
    news:[email protected]...
    >I need to get reference to one of the form in the workbook .
    >
    > So I loop through all the forms in the workbook and I get the
    > reference to
    > that form whose name starts with "frm_sr".
    >
    > So kindly tell me how I can refer to that form dynamically.
    >
    > Thanks
    >
    >
    >
    > "Chip Pearson" wrote:
    >
    >> > ActiveWorkbook.VBProject.VBComponents("forename") doesn't
    >> > calls
    >> > the
    >> > initialize event of the form.

    >>
    >> No it doesn't. Why would you think it would? From your earlier
    >> reply, it seems to me you don't need to use the VBProject
    >> object
    >> at all. What, exactly, are you trying to do?
    >>
    >>
    >> --
    >> Cordially,
    >> Chip Pearson
    >> Microsoft MVP - Excel
    >> Pearson Software Consulting, LLC
    >> www.cpearson.com
    >>
    >>
    >> "VJ" <[email protected]> wrote in message
    >> news:[email protected]...
    >> > Hi Chip,
    >> >
    >> > It seems to me that
    >> >
    >> > ActiveWorkbook.VBProject.VBComponents("formName") doesnt
    >> > calls
    >> > the
    >> > initialize event of the form.
    >> >
    >> > Thanks
    >> >
    >> >
    >> > "VJ" wrote:
    >> >
    >> >> I have four forms: form1, form2, form3 and form4
    >> >>
    >> >> when click on cmdbtn on form1, form2 shows up and in the
    >> >> initialize event of
    >> >> the form2 I am getting reference to either form3 or form4
    >> >> depending upon the
    >> >> logic. the name of the form4 is dynamic because I am
    >> >> importing
    >> >> the form4 from
    >> >> another workbook.
    >> >>
    >> >> I get the err in the initialize event of form2 where after
    >> >> getting reference
    >> >> to form3 or form4 I use varName.show.
    >> >>
    >> >> The varName referes to either form3 or form4 through
    >> >> binding.
    >> >>
    >> >> Ur help would be appreciated.
    >> >>
    >> >> Thanks
    >> >>
    >> >> "Chip Pearson" wrote:
    >> >>
    >> >> > Your code works fine for me. Exactly what problem do you
    >> >> > encounter?
    >> >> >
    >> >> >
    >> >> > --
    >> >> > Cordially,
    >> >> > Chip Pearson
    >> >> > Microsoft MVP - Excel
    >> >> > Pearson Software Consulting, LLC
    >> >> > www.cpearson.com
    >> >> >
    >> >> >
    >> >> > "VJ" <[email protected]> wrote in message
    >> >> > news:[email protected]...
    >> >> > > Does any one help me why I can't refer to the form with
    >> >> > > this
    >> >> > > method in VBA
    >> >> > > Excel.
    >> >> > >
    >> >> > > dim var_sr_form_name as object
    >> >> > > Set var_sr_form_name =
    >> >> > > ActiveWorkbook.VBProject.VBComponents("formName")
    >> >> > >
    >> >> > > I get error when I use
    >> >> > >
    >> >> > > var_sr_form_name.show method to show the form
    >> >> > >
    >> >> > > or try to access any component of the form.
    >> >> > >
    >> >> > > Thanks in advance for ur help.
    >> >> > >
    >> >> > > VJ
    >> >> >
    >> >> >
    >> >> >

    >>
    >>
    >>




  8. #8
    VJ
    Guest

    Re: Early and Late Binding Vba Excel

    Hey Chip,

    Thanks alot. it worked and really appreciate your help.

    Regards,

    "Chip Pearson" wrote:

    > Try something like
    >
    > Dim FrmName As String
    > Dim UF As Object
    > FrmName = "Userform1"
    >
    > Set UF = VBA.UserForms.Add(FrmName)
    > UF.Caption = "Hello, World"
    > UF.Show
    >
    >
    > --
    > Cordially,
    > Chip Pearson
    > Microsoft MVP - Excel
    > Pearson Software Consulting, LLC
    > www.cpearson.com
    >
    >
    >
    >
    > "VJ" <[email protected]> wrote in message
    > news:[email protected]...
    > >I need to get reference to one of the form in the workbook .
    > >
    > > So I loop through all the forms in the workbook and I get the
    > > reference to
    > > that form whose name starts with "frm_sr".
    > >
    > > So kindly tell me how I can refer to that form dynamically.
    > >
    > > Thanks
    > >
    > >
    > >
    > > "Chip Pearson" wrote:
    > >
    > >> > ActiveWorkbook.VBProject.VBComponents("forename") doesn't
    > >> > calls
    > >> > the
    > >> > initialize event of the form.
    > >>
    > >> No it doesn't. Why would you think it would? From your earlier
    > >> reply, it seems to me you don't need to use the VBProject
    > >> object
    > >> at all. What, exactly, are you trying to do?
    > >>
    > >>
    > >> --
    > >> Cordially,
    > >> Chip Pearson
    > >> Microsoft MVP - Excel
    > >> Pearson Software Consulting, LLC
    > >> www.cpearson.com
    > >>
    > >>
    > >> "VJ" <[email protected]> wrote in message
    > >> news:[email protected]...
    > >> > Hi Chip,
    > >> >
    > >> > It seems to me that
    > >> >
    > >> > ActiveWorkbook.VBProject.VBComponents("formName") doesnt
    > >> > calls
    > >> > the
    > >> > initialize event of the form.
    > >> >
    > >> > Thanks
    > >> >
    > >> >
    > >> > "VJ" wrote:
    > >> >
    > >> >> I have four forms: form1, form2, form3 and form4
    > >> >>
    > >> >> when click on cmdbtn on form1, form2 shows up and in the
    > >> >> initialize event of
    > >> >> the form2 I am getting reference to either form3 or form4
    > >> >> depending upon the
    > >> >> logic. the name of the form4 is dynamic because I am
    > >> >> importing
    > >> >> the form4 from
    > >> >> another workbook.
    > >> >>
    > >> >> I get the err in the initialize event of form2 where after
    > >> >> getting reference
    > >> >> to form3 or form4 I use varName.show.
    > >> >>
    > >> >> The varName referes to either form3 or form4 through
    > >> >> binding.
    > >> >>
    > >> >> Ur help would be appreciated.
    > >> >>
    > >> >> Thanks
    > >> >>
    > >> >> "Chip Pearson" wrote:
    > >> >>
    > >> >> > Your code works fine for me. Exactly what problem do you
    > >> >> > encounter?
    > >> >> >
    > >> >> >
    > >> >> > --
    > >> >> > Cordially,
    > >> >> > Chip Pearson
    > >> >> > Microsoft MVP - Excel
    > >> >> > Pearson Software Consulting, LLC
    > >> >> > www.cpearson.com
    > >> >> >
    > >> >> >
    > >> >> > "VJ" <[email protected]> wrote in message
    > >> >> > news:[email protected]...
    > >> >> > > Does any one help me why I can't refer to the form with
    > >> >> > > this
    > >> >> > > method in VBA
    > >> >> > > Excel.
    > >> >> > >
    > >> >> > > dim var_sr_form_name as object
    > >> >> > > Set var_sr_form_name =
    > >> >> > > ActiveWorkbook.VBProject.VBComponents("formName")
    > >> >> > >
    > >> >> > > I get error when I use
    > >> >> > >
    > >> >> > > var_sr_form_name.show method to show the form
    > >> >> > >
    > >> >> > > or try to access any component of the form.
    > >> >> > >
    > >> >> > > Thanks in advance for ur help.
    > >> >> > >
    > >> >> > > VJ
    > >> >> >
    > >> >> >
    > >> >> >
    > >>
    > >>
    > >>

    >
    >
    >


+ 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