+ Reply to Thread
Results 1 to 4 of 4

Select/Edit Textbox within a Chart in Word Copied from Excel

  1. #1
    Registered User
    Join Date
    09-03-2019
    Location
    Oregon
    MS-Off Ver
    2010
    Posts
    2

    Question Select/Edit Textbox within a Chart in Word Copied from Excel

    Hello,
    I'm new to the forums and very new to VBA. I feel like I've been able to accomplish quite a bit through internet searches, but I've come across something that I just can't find an answer to. I have an excel sheet that gathers data and formats it into charts using several macros controlled by buttons. I then have a SendtoWord macro that opens a specific Word template, copies each of the 20 charts, finds the appropriate bookmark in the Word document, and pastes each chart into the correct location (all one chart at a time). The charts are 2 in. x 3.5 in. in Excel so that I can see several at a time on the screen, but they are larger in Word because they're meant to be printed for posting around the office. As each chart is pasted into Word, the macro selects it and changes the size of the chart itself as well as the data label, legend, and title font sizes. Then it moves onto the next chart.

    Here comes the problem... I've added a text box to each of the charts in Excel. The text within the boxes updates every time the charts update. If I run my SendtoWord macro, it still works great as far as what I described above. The new text boxes do copy over with the charts, but I can't figure out how to then grab the text box to change the font size like I have with the other items.

    Here's the code that I currently have for one chart for the above process:
    Please Login or Register  to view this content.
    Note: LineChartHeight, LineChartWidth, ChartDataFont, and ChartTitleFont are predefined integers that I've set with the sizes that I want for each item.

    I understand (or at least I guess) that it will be handled differently because the textbox isn't a native object of the chart. Somehow I need to select the textbox within the selected chart. I've tried using the ShapeRange, TextFrame, and TextRange objects in different combinations. I even tried using InlineShapes(2) thinking that it might be seen as a different shape within the selected range. Also, there are other text boxes in the Word template that I don't want to change, so I can't just do a blanket change to all text boxes in the document.

    Is anyone able to help me figure out how to edit a textbox within a chart in Word from Excel VBA?

    Thank you very much ahead of time.

  2. #2
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    8,803

    Re: Select/Edit Textbox within a Chart in Word Copied from Excel

    Quote Originally Posted by Bryson White View Post
    I've added a text box to each of the charts in Excel.
    Can you better explain exactly how you added a textbox to a chart? Did you create an ActiveX Textbox and group it with the chart?

    Alternatively, instead of copying the chart to word, consider saving an image of the chart and then pasting the image in MSWord.

    Please Login or Register  to view this content.
    Surround your VBA code with CODE tags e.g.;
    [CODE]your VBA code here[/CODE]
    The # button in the forum editor will apply CODE tags around your selected text.

  3. #3
    Registered User
    Join Date
    09-03-2019
    Location
    Oregon
    MS-Off Ver
    2010
    Posts
    2

    Re: Select/Edit Textbox within a Chart in Word Copied from Excel

    I just used Insert > Text Box. Should I use an ActiveX Textbox from the developer tab?

    I did consider the copy image option. Copying the chart as an image doesn't allow for individually changing the font sizes of the different parts of the chart. Also, it stretches and makes it hard to read when the size of the chart/picture itself is changed.

    Thanks!

  4. #4
    Forum Guru
    Join Date
    07-25-2011
    Location
    Florida
    MS-Off Ver
    Excel 2003
    Posts
    8,803

    Re: Select/Edit Textbox within a Chart in Word Copied from Excel

    I got nothing, BW. Sorry.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1