Attaching a Textbox to a point or line on a chart in Excel/VBA -


i wondering how attach textbox point or line in excel chart macro working on. have been using .addtextbox method such

.shapes.addtextbox(msotextorientationhorizontal, 150, 250, 100, 15) _       .textframe.characters.text = "temperature" 

but have manually drag textbox on line on chart representing orientation of chart not line. there way convert line/point chart orientation use variable? or way? possibly using datalabel function, though want able customize 1 of axis locations. thanks

to solve question need left & top position of 2 objects:

  1. chart itself, position set in relation top-left corner of sheet range area
  2. point in series position set in relation top-left corner of chart

combination of both result following code (fixed parameters-required changes situation, more dynamic loop)

sub add_text_to_point()      dim tmpchr chartobject     set tmpchr = sheet1.chartobjects(1) 'put index of chartobject here      'for first serie, point 2nd here     '(change accordingly need)     tmpchr.chart.seriescollection(1).points(2)          sheet1.shapes.addtextbox(msotextorientationhorizontal, _                 .left + tmpchr.left, _                 .top + tmpchr.top, _                 100, 15) _                 .textframe.characters.text = "temperature"     end  end sub 

after result presenting picture below.

enter image description here


Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -