vba - How do I create a textbox in excel that fills a specific range? -
using vba, i'd able add , make sit on specific range, a2:h8
, example. possible?
i know alternatively merge bunch of cells , make text box way, hoping easier user move around if they'd to.
right i'm using generic add function, , trying in area want be. however, entire page going change due user input, depending on do, i'll need in different place. if tied specific range, in perfect place, no matter user does.
here's current little code snippet:
sub macro1() activesheet.shapes.addtextbox(msotextorientationhorizontal, 153.75, 88.5, 509.25, 272.25).select selection.shaperange(1).textframe2.textrange.characters.text = "hello hello hello" & chr(13) & "" & chr(13) & "hello" & chr(13) & "hi" & chr(13) & "" & chr(13) & "hello" selection.shaperange(1).textframe2.textrange.characters(1, 18).paragraphformat.firstlineindent = 0 selection.shaperange(1).textframe2.textrange.characters(1, 18).font .namecomplexscript = "+mn-cs" .namefareast = "+mn-ea" .fill.visible = msotrue .fill.forecolor.objectthemecolor = msothemecolordark1 .fill.forecolor.tintandshade = 0 .fill.forecolor.brightness = 0 .fill.transparency = 0 .fill.solid .size = 11 .name = "+mn-lt" end selection.shaperange(1).textframe2.textrange.characters(19, 1).paragraphformat.firstlineindent = 0 end sub
consider this:
sub coverrange() dim r range dim l long, t long, w long, h long set r = range("a2:h8") l = r.left t = r.top w = r.width h = r.height activesheet.shapes .addtextbox(msotextorientationhorizontal, l, t, w, h).select end end sub
Comments
Post a Comment