Overlapping in Paste

Sharkie21

Active Member
Joined
Nov 2, 2005
Messages
319
So far I got all my chart objects to copy and paste into word. However when I paste into word it just paste one ontop of the other. I want it to paste one after the other, but it doens't work :oops:

This is my code:

Code:
Public Sub ExportExcelGraph(wdObj As Word.Application, wdDoc As Word.Document)

Dim PC As ChartObject
Dim Wsht As Worksheet
On Error GoTo ErrHandler
For Each Wsht In ThisWorkbook.Worksheets
For Each PC In Wsht.ChartObjects
    PC.Activate
    ActiveChart.ChartArea.Select
    ActiveChart.ChartArea.Copy
    wdObj.Selection.PasteSpecial Link:=False, DataType:=wdPasteEnhancedMetafile, _
        Placement:=wdOneAfterAnother, DisplayAsIcon:=False
Next PC
Next Wsht

ErrHandler:
    Resume Next
End Sub
 

Some videos you may like

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,061
Office Version
  1. 365
Platform
  1. Windows
What you probably need to do is record a macro in Word when you move the charts to the desired position.

You should then be able to use that in your existing code.
 

Sharkie21

Active Member
Joined
Nov 2, 2005
Messages
319
I'm using word 2000. When I do a paste special since I don't want the link the only other option is a metafile. I wouldn't mind writing a macros in word to do the spacing, but these don't seem to act like an ordinary picture. I can't put my cursor after it and it doesn't add a new page when room runs out. Why is that happening?
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,061
Office Version
  1. 365
Platform
  1. Windows

ADVERTISEMENT

I really have no idea.

In the past I've had nightmares with using charts/pictures in Word, even without usingg code.
 

Sharkie21

Active Member
Joined
Nov 2, 2005
Messages
319
What I found out was if I copy multiple charts it'll add it to my clip board. And if I go to word and paste all, it's perfect. However, my clipboard will run out of room. Anyway to clear the clipboard with code and make it paste all with code?

According to the code to paste all it just does: selection.paste a bunch of times.

However, when I call this from word wdObj.selection.paste. It goes slow and keeps pasting the same chart over and over again even though there's 12 on the clipboard.
 

Sharkie21

Active Member
Joined
Nov 2, 2005
Messages
319

ADVERTISEMENT

bump. Hopefully someone will eventually answer this.
 

TrippyTom

Well-known Member
Joined
Nov 16, 2004
Messages
587
1) Right click each picture
2) Choose Format Picture
3) Click the Layout tab
4) Make sure this is set to "In line with text"

This will allow you to position them one after another. Is that what you needed?
 

Sharkie21

Active Member
Joined
Nov 2, 2005
Messages
319
That seems to work! However when I try to do it through a macro it grey's out the option WHY!!!! :eek:
 

Sharkie21

Active Member
Joined
Nov 2, 2005
Messages
319
OMG It works!!!!!!

I needed this line.

wdObj.Selection.ShapeRange.ConvertToInlineShape

Thank you Norie and TrippyTom!!!
 

Watch MrExcel Video

Forum statistics

Threads
1,118,760
Messages
5,574,088
Members
412,566
Latest member
TexasTony
Top