Excel to Word - Inserting Chart and Comment with Excel filename inside

reganhayward

New Member
Joined
Jun 29, 2012
Messages
2
Hi guys

This should be a simple one...

I've got some code in Excel which formats my charts, then I have some more code to copy in my chart to Word
All fine so far,
But I want to insert a comment when I insert the chart with a hyperlink to the Excel location, so the next user knows the location.
But for the life of me I cant get it working.

Ive tried this from inside Word and it works fine

ActiveDocument.Comments.Add Range:=Selection.Range, _ Text:="review this"</pre>
But when I try that code from Excel, it gives me an error


Any ideas?


here's my current code:

Dim WDApp As Word.Application
Dim WDDoc As Word.Document


' Make sure a chart is selected
If ActiveChart Is Nothing Then
MsgBox "Please select a chart and try again.", vbExclamation, _
"No Chart Selected"
Else
' Reference existing instance of Word
Set WDApp = GetObject(, "Word.Application")
' Reference active document
Set WDDoc = WDApp.ActiveDocument

' Copy chart as a picture
ActiveChart.CopyPicture Appearance:=xlScreen, Size:=xlScreen, _
Format:=xlPicture


'Paste chart at cursor position
WDApp.Selection.PasteSpecial Link:=False, DataType:=wdPasteMetafilePicture, _
Placement:=wdInLine, DisplayAsIcon:=False

'Insert comment here...
WDApp.Selection.Comments.Add Range:=Selection.Range, Text:="Comment text"




Thanks in advance

Regan
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,214,628
Messages
6,120,618
Members
448,973
Latest member
ChristineC

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top