VBA in Excel and Microsoft Word

Jason_Moffitt

New Member
Joined
Oct 24, 2008
Messages
8
<HR style="COLOR: #ffffff; BACKGROUND-COLOR: #ffffff" SIZE=1><!-- / icon and title --><!-- message -->I have a spreadsheet that pulls reporting values based on the data validation list that I pull down in one of the cells. Once the calculation occurs and updates all the information...mainly graphs, I want to grab the print area, copy it and then paste it as a picture into a word document.

In the posts I have seen in the past, most comments go towards, simply record your actions in word after you load the reference and you should be fine...however, I get an error when trying to post as a picture...I can do a standard paste just fine, but then the formatting and size of the report within Word is completely messed up.

Any thoughts on why I would get this error, or what command I should use instead?

error is: Microsoft Visual Basic, Run Time error '4605': This command is not available

code is below

Quote:
<TABLE cellSpacing=0 cellPadding=6 width="100%" border=0><TBODY><TR><TD class=alt2 style="BORDER-RIGHT: 1px inset; BORDER-TOP: 1px inset; BORDER-LEFT: 1px inset; BORDER-BOTTOM: 1px inset">Sub Generate_Report_Test()
'
'To scan through selected reports choices, generate reports and paste into a word
'document as pictures to be sent to team
'turn off screen flicker while macro is running
'Application.ScreenUpdating = False



Range("D2").Select
Range("F2").Select
Calculate

'copy Report Data

Range("B4:G26").Select
Selection.Copy

'starting Word document
Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim i As Integer
Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add


'set up page settings for report
With wrdDoc.PageSetup
.Orientation = wdOrientLandscape
.TopMargin = InchesToPoints(0.7)
.BottomMargin = InchesToPoints(0.7)
.LeftMargin = InchesToPoints(0.7)
.RightMargin = InchesToPoints(0.7)
End With

'Paste Report Data
With wrdDoc
wrdApp.Selection.PasteAndFormat wdChartPicture 'this is highlighted error
wrdApp.Selection.TypeParagraph
End With
</TD></TR></TBODY></TABLE>
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes

Forum statistics

Threads
1,215,412
Messages
6,124,761
Members
449,187
Latest member
hermansoa

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