Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default copy excel char to specific page in Word (VBA)

Hi,

I'm using Office 2003. Using VBA, I'd like to copy and paste a chart onto
page 6 of a Word document/template. The below code copies and pastes to page
1. Any ideas what I have to add to:
A) specify the page
B) specify the position of the chart on the page, and
C) give the chart a 'name' that can be referenced later within the macro
(i.e., rather than some arbitrary number that Word might give it).

Thanks for any ideas.

Sub copy_charts_Word()

Dim role_chart_sh As Shape

Dim MSW As Word.Application
Dim MSWfile As Word.Document

Set MSW = New Word.Application
MSW.Visible = msoCTrue
Set MSWfile = MSW.Documents.Open("C:\Report_template.doc")

Set role_chart_sh = Worksheets("Chart_Role").Shapes(1)
role_chart_sh.CopyPicture Appearance:=xlScreen, Format:=xlPicture

MSW.Selection.PasteSpecial Link:=False, DataType:=wdPasteMetafilePicture,_
Placement:=wdInLine, DisplayAsIcon:=False

End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default copy excel char to specific page in Word (VBA)

It is probably best to use a field code. You add field code when you add a
caption to a picture using in word insert - reference - caption. You can see
the field codes by going to the word menu Tools - Options - View and select
field Codes.

to find out how to select a particula area of a word document I would
recommend asking the Microsoft Word Guru's. Word is much more difficult to
work with than an excel document.

I may be better to write the macro in word than in excel. Word can open an
excel document just like excel can open the word document.

"intoit" wrote:

Hi,

I'm using Office 2003. Using VBA, I'd like to copy and paste a chart onto
page 6 of a Word document/template. The below code copies and pastes to page
1. Any ideas what I have to add to:
A) specify the page
B) specify the position of the chart on the page, and
C) give the chart a 'name' that can be referenced later within the macro
(i.e., rather than some arbitrary number that Word might give it).

Thanks for any ideas.

Sub copy_charts_Word()

Dim role_chart_sh As Shape

Dim MSW As Word.Application
Dim MSWfile As Word.Document

Set MSW = New Word.Application
MSW.Visible = msoCTrue
Set MSWfile = MSW.Documents.Open("C:\Report_template.doc")

Set role_chart_sh = Worksheets("Chart_Role").Shapes(1)
role_chart_sh.CopyPicture Appearance:=xlScreen, Format:=xlPicture

MSW.Selection.PasteSpecial Link:=False, DataType:=wdPasteMetafilePicture,_
Placement:=wdInLine, DisplayAsIcon:=False

End Sub

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
hyperlinking to a specific page of a word document Miranda Excel Discussion (Misc queries) 1 September 16th 09 11:23 PM
PROBLEM:How to squeeze 2 Page sized Chart in Excel 2000 & embed in Word 2000 and print from Word to fit one page ??? [email protected] New Users to Excel 2 September 10th 08 11:07 AM
Hyperlinks to a Specific Page in Word doc.. agilbert66 Excel Discussion (Misc queries) 2 May 29th 07 04:39 PM
search for a specific word and copy the word and the preceeding words until a comma DHANANJAY Excel Programming 12 December 31st 05 12:53 PM
How do I copy a Word text file into Excel in a way that each char. Newtech programmer Excel Discussion (Misc queries) 2 April 15th 05 07:07 PM


All times are GMT +1. The time now is 10:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"