Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
robert_mika
Master III
Master III

Create Text box x20 in VBA

I'm looking for a code to create x (5,10.....)numbers of Textboxes.

With  the ability to change parameters (Width and Hight)

1 Solution

Accepted Solutions
m_woolf
Master II
Master II

The code works for me. I have attached a qvw.

View solution in original post

4 Replies
m_woolf
Master II
Master II

Maybe this will get you started:

sub test

  for i = 1 to 20

  set mytext = ActiveDocument.ActiveSheet.CreateTextObject

  strObjID = mytext.GetObjectID

  set fr = mytext.GetFrameDef

     pos = fr.Rect

     pos.Top = i*60

     pos.Left = i*60

  pos.Width = 60

  pos.Height = 90

     mytext.SetFrameDef fr

  ' strBkgColor =  BkgColor(strEventType)

  '     strBkgColor = "200,200,200"

  BGColorArray = Split(strBkgColor, ",", -1, 1)

  set prop = mytext.GetProperties

  prop.Layout.Text.v = strObjID

  ' prop.Layout.Frame.HelpText.v =strNewObjectID

  prop.Layout.BkgAlpha = 255  'Transparency 0%

  ' prop.Layout.BkgColor.PrimaryCol.Col = RGB(CInt(BGColorArray(0)),CInt(BGColorArray(1)),CInt(BGColorArray(2)))

  prop.Layout.TextColor.PrimaryCol.Col = RGB(0,0,0)

  prop.Layout.Frame.ZedLevel = 1

     prop.Layout.Frame.Show.Always = true

  prop.Layout.Frame.Show.Expression.v = 0

  prop.Layout.BottomMargin = 0

  prop.Layout.TopMargin = 0

  prop.Layout.LeftMargin = 0

  prop.Layout.RightMargin = 0

  mytext.SetProperties prop

  next

end sub

robert_mika
Master III
Master III
Author

Thanks.

I'm getting error:

'Expected statement'

Capture.PNG

m_woolf
Master II
Master II

The code works for me. I have attached a qvw.

robert_mika
Master III
Master III
Author

Thank you m w.

Silly mistake from my side:

Forgot the first sub line...