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

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.

Forum statistics

Threads
1,223,705
Messages
6,173,991
Members
452,541
Latest member
haasro02

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