+ Reply to Thread
Results 1 to 16 of 16

Excel Com Addin

Hybrid View

  1. #1
    Nick Hebb
    Guest

    Re: Excel Com Addin

    Sorry, I could have been a little more detailed. here is a sample that
    shows what I'm talking about:

    Sub tryIt()
    Dim res As Range
    Dim def As Range

    Set def = Application.Selection

    Set res = Application.InputBox("Select the range of cells",
    Type:=8, _
    Default:=def.AddressLocal)

    MsgBox res.Address

    End Sub

    The Type:=8 tells it to let the user select a range. The
    Default:=def.AddressLocal gets the range the user already has selected.
    This way, if the user already has a range selected, they only have to
    click OK, but if they initiated the action and didn't realize they
    needed to pre-select the range, the InputBox allows to select it.

    Also, to make sure your application is robust, you should verify the
    type of the Selection before assigning it to the def range object. The
    user's current selection could be a chart or an autoshape, either of
    which would cause the above sample to throw an error.


  2. #2
    Tushar Mehta
    Guest

    Re: Excel Com Addin

    Yes, I know what you were referring to. But note that the OP is
    writing a .Net DLL that will be used as a COM Add-In. Consequently,
    one doesn't have access to 'Application' but needs to establish one at
    add-in initialization time through a variable s/he declares in the COM
    Add-in.

    Further, and you may already know the answer to this, but I don't, one
    should check the interaction between XL, the COM Add-In, and the XL
    InputBox dialog box. Will it still be modal? I know that if one has a
    userform in a COM Add-In, one needs to take special steps to make it
    modal and to ensure it shows within the XL window. Further, it is not
    possible to use a RefEdit control in such a userform. Well, one can
    create one but it doesn't work. Does InputBox with Type=8 have the
    same problem?

    --
    Regards,

    Tushar Mehta
    www.tushar-mehta.com
    Excel, PowerPoint, and VBA add-ins, tutorials
    Custom MS Office productivity solutions

    In article <1118378498.397110.257700@o13g2000cwo.googlegroups.com>,
    n.hebb@comcast.net says...
    > Sorry, I could have been a little more detailed. here is a sample that
    > shows what I'm talking about:
    >
    > Sub tryIt()
    > Dim res As Range
    > Dim def As Range
    >
    > Set def = Application.Selection
    >
    > Set res = Application.InputBox("Select the range of cells",
    > Type:=8, _
    > Default:=def.AddressLocal)
    >
    > MsgBox res.Address
    >
    > End Sub
    >
    > The Type:=8 tells it to let the user select a range. The
    > Default:=def.AddressLocal gets the range the user already has selected.
    > This way, if the user already has a range selected, they only have to
    > click OK, but if they initiated the action and didn't realize they
    > needed to pre-select the range, the InputBox allows to select it.
    >
    > Also, to make sure your application is robust, you should verify the
    > type of the Selection before assigning it to the def range object. The
    > user's current selection could be a chart or an autoshape, either of
    > which would cause the above sample to throw an error.
    >
    >


  3. #3
    Robert Bruce
    Guest

    Re: Excel Com Addin

    Roedd <<Tushar Mehta>> wedi ysgrifennu:


    > Further, and you may already know the answer to this, but I don't, one
    > should check the interaction between XL, the COM Add-In, and the XL
    > InputBox dialog box. Will it still be modal? I know that if one has
    > a userform in a COM Add-In, one needs to take special steps to make it
    > modal and to ensure it shows within the XL window. Further, it is not
    > possible to use a RefEdit control in such a userform. Well, one can
    > create one but it doesn't work. Does InputBox with Type=8 have the
    > same problem?
    >


    FWIW, I once created an ActiveX control for forms in VB6 dlls that emulated
    the RefEdit using a textbox, a commandbutton and Excel's Inputbox. It worked
    superbly. I was going to bring it up to commercial standard, but I didn't
    think the audience was there and then along came .NET

    <unhelpful>I have not the slightest idea whether a similar .NET control
    could be created.</unhelpful>

    --
    Rob

    http://www.asta51.dsl.pipex.com/webcam/

    This message is copyright Robert Bruce and intended
    for distribution only via NNTP.
    Dissemination via third party Web forums with the
    exception of Google Groups and Microsoft Communities
    is strictly prohibited and may result in legal action.



  4. #4
    Tushar Mehta
    Guest

    Re: Excel Com Addin

    I did something similar (refedit in a userform shown from a COM Add-in)
    using a 2nd userform. Using XL's InputBox didn't occur to me. Goes to
    show how often I call on it. {grin}

    Anyway, the files describing the technique have been added to the other
    gazillion files in my 'tutorials for the website' folder. {grin}

    --
    Regards,

    Tushar Mehta
    www.tushar-mehta.com
    Excel, PowerPoint, and VBA add-ins, tutorials
    Custom MS Office productivity solutions

    In article <e3sJlVbbFHA.2756@tk2msftngp13.phx.gbl>, rob@analytical-
    dynamicsdotcodotukay says...
    > Roedd <<Tushar Mehta>> wedi ysgrifennu:
    >
    >
    > > Further, and you may already know the answer to this, but I don't, one
    > > should check the interaction between XL, the COM Add-In, and the XL
    > > InputBox dialog box. Will it still be modal? I know that if one has
    > > a userform in a COM Add-In, one needs to take special steps to make it
    > > modal and to ensure it shows within the XL window. Further, it is not
    > > possible to use a RefEdit control in such a userform. Well, one can
    > > create one but it doesn't work. Does InputBox with Type=8 have the
    > > same problem?
    > >

    >
    > FWIW, I once created an ActiveX control for forms in VB6 dlls that emulated
    > the RefEdit using a textbox, a commandbutton and Excel's Inputbox. It worked
    > superbly. I was going to bring it up to commercial standard, but I didn't
    > think the audience was there and then along came .NET
    >
    > <unhelpful>I have not the slightest idea whether a similar .NET control
    > could be created.</unhelpful>
    >
    >


  5. #5
    Nick Hebb
    Guest

    Re: Excel Com Addin

    >>Yes, I know what you were referring to

    Nothing personal Tushar, but I wasn't replying to you. It was a follow
    up to the OP based on her comments above, subsequent to my first post.
    The use of "Application" was just for the sample code - having a local
    variable referencing the Application is fundamental with COM Add-ins so
    I didn't think it was worth mentioning.

    I haven't tried it, but through Interop the modality of the
    Application.InputBox should be the same (i.e., non-modal).


+ 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