How do you place a textbox object over a specific Cell when automating Excel?

后端 未结 2 942
囚心锁ツ
囚心锁ツ 2021-01-13 16:09

We are automating Excel using VB.Net, and trying to place multiple lines of text on an Excel worksheet that we can set to not print. Between these we would have printable re

相关标签:
2条回答
  • 2021-01-13 16:22

    When you copy & paste a textbox, Excel will place the new textbox over whichever cell is currently selected. So you can achieve this very easily by simply using the VBA copy & paste commands. This can be particularly useful if you are going to be using a lot of very similar textboxes, as you are effectively creating a textbox template.

    0 讨论(0)
  • 2021-01-13 16:23

    If you have the cell name or position, you can do:

    With ActiveSheet
      .Shapes.AddTextbox msoTextOrientationHorizontal, .Cells(3,2).Left, .Cells(3,2).Top, .Cells(3,2).Width, .Cells(3,2).Height
    End With
    

    This will add a textbox over cell B3. When B3 is resized, the textbox is also.

    0 讨论(0)
提交回复
热议问题