none
User Drawn Textbox on Button Click? RRS feed

  • Question

  • I am developing a Word Add-in, and I want the user to be able to click a button and be able to draw a textbox in the document. 

    I've found documentation on inserting a textbox to a static location, but not on how to enable the drawing controls to get a user defined location and size. 

    Basically I would like the same functionality as if you hit the "Draw Text Box" button on the Insert tab in Word 2013. 

    Any ideas?

    Thanks

    Wednesday, February 3, 2016 2:34 PM

Answers

  • >>>Basically I would like the same functionality as if you hit the "Draw Text Box" button on the Insert tab in Word 2013.

    According to your description, I suggest that you could use CommandBars.ExecuteMso method to execute built-in "Draw Text Box" button, please refer to below:

    Add->New Item->Ribbon(Visual Designer), input name
    Drag and Drop one Button on your custom Ribbon, refer to below screenshot:

    private void button1_Click(object sender, RibbonControlEventArgs e)
    {
        Globals.ThisAddIn.Application.CommandBars.ExecuteMso("TextBoxInsert");
    }

    For more information, click here to refer about CommandBars.ExecuteMso Method (Office)

    • Proposed as answer by David_JunFeng Friday, February 5, 2016 1:10 AM
    • Marked as answer by David_JunFeng Tuesday, February 16, 2016 9:47 AM
    Thursday, February 4, 2016 5:19 AM