ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Charts and Charting in Excel (https://www.excelbanter.com/charts-charting-excel/)
-   -   Pasting charts to Word from Excel as picture (https://www.excelbanter.com/charts-charting-excel/97437-pasting-charts-word-excel-picture.html)

Hari

Pasting charts to Word from Excel as picture
 
Hi,

I want to transfer some charts (as picture) in excel to a particular
word document (specific page and specific position). The word document
already has some data and lots of pages in it and Im inserting charts
in specific places.

When I used to do the above task for Excel to Power- point then I could
use the, Right click Format picture, of Size (Height, Width) and
Position on Slide (Horizontal, Vertical) in order to place the charts
in powerpoint in the exact position and dimension I want.

But Im not able to see an analogous feature in word where I could
specify the Position (Position on page - Horizontal and Vertical) of
object/chart in Word. When I do right click on a picture in Word, then
size tab has height and width (Good for me), but I dont have any tab
for position. What we do have is a tab called Layout, in which the
"Advanced" button has Absolute position ... to of the column and
Absolute position .... below paragraph. Im not sure whether by using
these 2 properties I will be able to position my chart in the place I
want.

Again, I have not been able to try the above because of 2 reasons:-

a) If I copy paste a chart named as Chart1 in excel to Winword then
what is the name of that object in word? For checking this I recorded a
macro in word where I selected a newly pasted chart from excel and see
that the code it produces is

ActiveDocument.Shapes("Group 1570").Select

Knowin the name of the chart in word seemed important to me, because as
soon as im done pasting, the cursor in word moves to the new line or
rather the chart object is no longer active in word. So, if it is not
active then how do I apply positional and size properties to it?

b) Secondly, Im not sure of the of the exact syntax for applying
positional and size properties. When I record a macro in word where I
change the Height/width/Abs Position Col/ Abs Position Para to 2 inches
then I get lot of recorded code out of which following seemed relevant
to me (I have snipped rest).

Selection.ShapeRange.Height = 144#
Selection.ShapeRange.Width = 144#
Selection.ShapeRange.Left = 180#
Selection.ShapeRange.Top = 126#
Selection.ShapeRange.Left = InchesToPoints(2)
Selection.ShapeRange.Top = InchesToPoints(2)

Im not able to understand as to why the Left and Top (Probably the
positonal parameters for object) is getting recorded twice and that too
in different units (once as 180# and another time as
InchesToPoints(2)).

Also, I want to know one more thing. As I have already mentioned I have
text data in word and I have left enough space so that when a new chart
gets pasted the text data below the chart doesnt get shifted down. For
example, in the below code Im first navigating to the page where I want
to paste chart and then pasting it. In this whats happening is that,
even my page title and rest text gets shifted. How to avoid this
situation

Sub StartTransferProcess(WkbookNam As String, ShtNam As String, ChtNam
As String, _
Pageno As Byte, Height As Double, Width As Double, ColPos As Double,
ParPos As Double)

Set SWinword = GetObject(, "Word.application")
Set Sdocument = SWinword.Documents(WordDocName)

Workbooks(WkbookNam & ".xls").Activate
Sheets(ShtNam).Select
ActiveSheet.ChartObjects(ChtNam).Activate
ActiveChart.ChartArea.Select
ActiveChart.ChartArea.Copy

Sdocument.Activate
Sdocument.ActiveWindow.Selection.GoTo What:=wdGoToPage,
Which:=wdGoToNext, Name:=Pageno
Sdocument.ActiveWindow.Selection.Paste

''' New code to be written for Positioning and sizing object

End Sub

Regards,
HP
India


Hari

Pasting charts to Word from Excel as picture
 
Hi,

I have some more queries.

My colleague has pasted the charts (manually) from excel to PPT as
picture. When I do rightclick on these charts then :-

a) There is a circular green handle on top centre of the object (along
with 8 white circles on corner and rest centres)

b) If I select format picture from right click then Layout tab has the
option "In front of text" for wrapping style. Consequently, the
advanced button in layout tab has further options available for the
Picture position tab.

On the other hand, when I paste charts from excel to Word (whether
manually or through code) then, the pasted chart has these properties
when I right click on it:-

a) There is NO green handle, rather clicking gives me 8 black square
handles.

b) If I select format picture from right click then Layout tab has the
option "In line with text for wrapping style. Consequently, the
advanced button in layout tab has NO further options available for the
Picture position tab.

My question is how do I ensure that when I paste chart from excel to
word (using code) then it gets pasted as "In front of text" wrapping
style option.

Regards,
HP
India


HEK

Pasting charts to Word from Excel as picture
 
Dear Hari:
I believe this is more a Word issue than an Excel issue and maybe in the
Word forum you can get better help. Anyway, I will try.
You can select a default mode for inserting pictures in Word. I hv Word
2003, and here u can do that under Tools/Options/[Edit Tab], and find
"Insert/Paste pictures as.." and select the mode you want.
Frankly, floating pictures in front of text is never my choice. In line
with text always insert a picture properly. Two remarks:
1. You can use a table to control the size and positioning of graphics.
Choose fixed table cell and make the lines of the table invisible. This way
of using tables is fairly unknown.
2. You can paste the picture with a dynamic link to Excel. This is
particular convenient when you change the source; you dont then have to redo
the copy/pasting; it willbe automatically updated. For this select as Paste
Special in Word and select the radio button 'Paste Link'.
I hope this helps.
GH,
Henk
"Hari" wrote:

Hi,

I have some more queries.

My colleague has pasted the charts (manually) from excel to PPT as
picture. When I do rightclick on these charts then :-

a) There is a circular green handle on top centre of the object (along
with 8 white circles on corner and rest centres)

b) If I select format picture from right click then Layout tab has the
option "In front of text" for wrapping style. Consequently, the
advanced button in layout tab has further options available for the
Picture position tab.

On the other hand, when I paste charts from excel to Word (whether
manually or through code) then, the pasted chart has these properties
when I right click on it:-

a) There is NO green handle, rather clicking gives me 8 black square
handles.

b) If I select format picture from right click then Layout tab has the
option "In line with text for wrapping style. Consequently, the
advanced button in layout tab has NO further options available for the
Picture position tab.

My question is how do I ensure that when I paste chart from excel to
word (using code) then it gets pasted as "In front of text" wrapping
style option.

Regards,
HP
India



Hari

Pasting charts to Word from Excel as picture
 

HEK wrote:
Dear Hari:
I believe this is more a Word issue than an Excel issue and maybe in the
Word forum you can get better help. Anyway, I will try.
You can select a default mode for inserting pictures in Word. I hv Word
2003, and here u can do that under Tools/Options/[Edit Tab], and find
"Insert/Paste pictures as.." and select the mode you want.
Frankly, floating pictures in front of text is never my choice. In line
with text always insert a picture properly. Two remarks:
1. You can use a table to control the size and positioning of graphics.
Choose fixed table cell and make the lines of the table invisible. This way
of using tables is fairly unknown.


Could you please let me know as to how one can use tables to fix the
position.

Also, I can make the lines semi-invisible, which is they dont get
printed, but yet once can see the table borders. How to make them
completely invisible?

2. You can paste the picture with a dynamic link to Excel. This is
particular convenient when you change the source; you dont then have to redo
the copy/pasting; it willbe automatically updated. For this select as Paste
Special in Word and select the radio button 'Paste Link'.


I need to send this word file across to others and I prefer to not link
it other files.

I hope this helps.
GH,
Henk
"Hari" wrote:

Hi,

I have some more queries.

My colleague has pasted the charts (manually) from excel to PPT as
picture. When I do rightclick on these charts then :-

a) There is a circular green handle on top centre of the object (along
with 8 white circles on corner and rest centres)

b) If I select format picture from right click then Layout tab has the
option "In front of text" for wrapping style. Consequently, the
advanced button in layout tab has further options available for the
Picture position tab.

On the other hand, when I paste charts from excel to Word (whether
manually or through code) then, the pasted chart has these properties
when I right click on it:-

a) There is NO green handle, rather clicking gives me 8 black square
handles.

b) If I select format picture from right click then Layout tab has the
option "In line with text for wrapping style. Consequently, the
advanced button in layout tab has NO further options available for the
Picture position tab.

My question is how do I ensure that when I paste chart from excel to
word (using code) then it gets pasted as "In front of text" wrapping
style option.

Regards,
HP
India




HEK

Pasting charts to Word from Excel as picture
 
Hari:
Just define a table as u normally do. Use the cells as sections on yr page
where u can put in yr information. By doing it cleverly u can make a
brochure for instance.

Indeed, removing the borders let them show a light-grey still on screen yet
they will not print. I dont think there is a way to make them completely
invisible, and I wldnt recommend that anyway as it may not be easy anymore to
see what you'r doing. However, if you convert to pdf they also disappear as
any print file.
You can define the table cell via Table/Table Properties with a fixed width,
meaning that it will not size to its contents but remain the dimensions you
set. If you put in a chart it will assume the dimensions of the cell I think
(I havent tested this at length).

If you send a linked file to others who dont hv the source file this will hv
no effect, although they shd hv unchecked the option in Word to automatically
update when opening the file as otherwise it will run dead by looking for the
source file without success obviously.

Regards,
Henk


"Hari" wrote:


HEK wrote:
Dear Hari:
I believe this is more a Word issue than an Excel issue and maybe in the
Word forum you can get better help. Anyway, I will try.
You can select a default mode for inserting pictures in Word. I hv Word
2003, and here u can do that under Tools/Options/[Edit Tab], and find
"Insert/Paste pictures as.." and select the mode you want.
Frankly, floating pictures in front of text is never my choice. In line
with text always insert a picture properly. Two remarks:
1. You can use a table to control the size and positioning of graphics.
Choose fixed table cell and make the lines of the table invisible. This way
of using tables is fairly unknown.


Could you please let me know as to how one can use tables to fix the
position.




Also, I can make the lines semi-invisible, which is they dont get
printed, but yet once can see the table borders. How to make them
completely invisible?

2. You can paste the picture with a dynamic link to Excel. This is
particular convenient when you change the source; you dont then have to redo
the copy/pasting; it willbe automatically updated. For this select as Paste
Special in Word and select the radio button 'Paste Link'.


I need to send this word file across to others and I prefer to not link
it other files.

I hope this helps.
GH,
Henk
"Hari" wrote:

Hi,

I have some more queries.

My colleague has pasted the charts (manually) from excel to PPT as
picture. When I do rightclick on these charts then :-

a) There is a circular green handle on top centre of the object (along
with 8 white circles on corner and rest centres)

b) If I select format picture from right click then Layout tab has the
option "In front of text" for wrapping style. Consequently, the
advanced button in layout tab has further options available for the
Picture position tab.

On the other hand, when I paste charts from excel to Word (whether
manually or through code) then, the pasted chart has these properties
when I right click on it:-

a) There is NO green handle, rather clicking gives me 8 black square
handles.

b) If I select format picture from right click then Layout tab has the
option "In line with text for wrapping style. Consequently, the
advanced button in layout tab has NO further options available for the
Picture position tab.

My question is how do I ensure that when I paste chart from excel to
word (using code) then it gets pasted as "In front of text" wrapping
style option.

Regards,
HP
India





Ed

Pasting charts to Word from Excel as picture
 
Hari:

When you copy from Excel, use CopyAsPicture. This automatically
creates a picture file. When you paste into Word, use InFrontOfText,
and you should be able to specify exactly where you want it relative to
page, margin, or others (depending on whather ou're setting the
horizontal or vetical position). You don't have to worry about the
green circles unless you're intending to rotate the graphic.

I wrote the following in Word (2002). It should work in Excel if you
preface the range and objects with your Word application object. I
would test it by creating a blank Word document with several empty
pages, and then select a picture from somewhere and copy it. The macro
sets your document, takes you to a specific page (page 2, in this
case), sets a range at the first character position there and pastes in
a picture. (So copy a picture first to have it on the clipboard before
you run this; otherwise you'll get an error.) When the picture is
pasted, it is considered an InlineShape. It is converted to a
ShapeRange object, which then allows you to set the Top and Relative
positions. Check the Help files for ShapeRange.

HTH
Ed

Sub TestPasteFormatPicture()

Dim doc As Document
Dim rng As Range
Dim objSh As Shape

Set doc = ActiveDocument

Set rng = Selection.GoTo(What:=wdGoToPage, Which:=wdGoToNext,
Name:="2")

rng.Paste
rng.MoveEnd wdCharacter, 1
rng.InlineShapes(1).ConvertToShape
Set objSh = rng.ShapeRange

End Sub


HEK wrote:
Hari:
Just define a table as u normally do. Use the cells as sections on yr page
where u can put in yr information. By doing it cleverly u can make a
brochure for instance.

Indeed, removing the borders let them show a light-grey still on screen yet
they will not print. I dont think there is a way to make them completely
invisible, and I wldnt recommend that anyway as it may not be easy anymore to
see what you'r doing. However, if you convert to pdf they also disappear as
any print file.
You can define the table cell via Table/Table Properties with a fixed width,
meaning that it will not size to its contents but remain the dimensions you
set. If you put in a chart it will assume the dimensions of the cell I think
(I havent tested this at length).

If you send a linked file to others who dont hv the source file this will hv
no effect, although they shd hv unchecked the option in Word to automatically
update when opening the file as otherwise it will run dead by looking for the
source file without success obviously.

Regards,
Henk


"Hari" wrote:


HEK wrote:
Dear Hari:
I believe this is more a Word issue than an Excel issue and maybe in the
Word forum you can get better help. Anyway, I will try.
You can select a default mode for inserting pictures in Word. I hv Word
2003, and here u can do that under Tools/Options/[Edit Tab], and find
"Insert/Paste pictures as.." and select the mode you want.
Frankly, floating pictures in front of text is never my choice. In line
with text always insert a picture properly. Two remarks:
1. You can use a table to control the size and positioning of graphics.
Choose fixed table cell and make the lines of the table invisible. This way
of using tables is fairly unknown.


Could you please let me know as to how one can use tables to fix the
position.




Also, I can make the lines semi-invisible, which is they dont get
printed, but yet once can see the table borders. How to make them
completely invisible?

2. You can paste the picture with a dynamic link to Excel. This is
particular convenient when you change the source; you dont then have to redo
the copy/pasting; it willbe automatically updated. For this select as Paste
Special in Word and select the radio button 'Paste Link'.


I need to send this word file across to others and I prefer to not link
it other files.

I hope this helps.
GH,
Henk
"Hari" wrote:

Hi,

I have some more queries.

My colleague has pasted the charts (manually) from excel to PPT as
picture. When I do rightclick on these charts then :-

a) There is a circular green handle on top centre of the object (along
with 8 white circles on corner and rest centres)

b) If I select format picture from right click then Layout tab has the
option "In front of text" for wrapping style. Consequently, the
advanced button in layout tab has further options available for the
Picture position tab.

On the other hand, when I paste charts from excel to Word (whether
manually or through code) then, the pasted chart has these properties
when I right click on it:-

a) There is NO green handle, rather clicking gives me 8 black square
handles.

b) If I select format picture from right click then Layout tab has the
option "In line with text for wrapping style. Consequently, the
advanced button in layout tab has NO further options available for the
Picture position tab.

My question is how do I ensure that when I paste chart from excel to
word (using code) then it gets pasted as "In front of text" wrapping
style option.

Regards,
HP
India







All times are GMT +1. The time now is 12:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com