Run time error 462

TheShaunMichael

Board Regular
Joined
Oct 24, 2009
Messages
57
Hello fellow VBA-ers,

I have a very long macro that uses data in excel to create estimates with paragraphs, tables, pictures and so on. It works perfectly every other time I run it. When it fails, I get run time error 462 and it points me to what I have colored below in red. This is the very beginning of my macro and I believe it has something to do with how I've set the wrdApp and wrdDoc labels.

Any help is greatly appreciated!



Set wrdApp = CreateObject("Word.Application")
Set EI = Worksheets("Estimate Info")
Z = ActiveCell.Row
wrdApp.Visible = True
Set wrdDoc = wrdApp.Documents.Add

wrdDoc.Content.Style = "No Spacing"

wrdDoc.PageSetup.DifferentFirstPageHeaderFooter = True
wrdDoc.Sections(1).Headers(wdHeaderFooterFirstPage).Shapes.AddPicture ("C:\Users\User\Desktop\Picture1.jpg")
wrdDoc.Sections(1).Headers(wdHeaderFooterFirstPage).Shapes.AddPicture ("C:\Users\User\Desktop\Picture2.jpg")

With wrdDoc.Sections(1).Headers(wdHeaderFooterFirstPage).Shapes(1)
.Left = InchesToPoints(0)
.RelativeHorizontalPosition = wdRelativeHorizontalPositionLeftMarginArea
.Top = InchesToPoints(0.5)
.RelativeVerticalPosition = wdRelativeVerticalPositionParagraph
.Width = 70
End With
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
I don't think it's connected to you references to Word or the document, InchesToPoints is available in Excel and Word.

Mind you perhaps there's a difference between the Excel and Word version/use.

Have you tried wrdApp.InchesToPoints?

By the way, do you need InchesToPoints(0)?

The result is 0.

PS Just did a quick test, in Excel you need Application.InchesToPoints.
 
Upvote 0

Forum statistics

Threads
1,224,599
Messages
6,179,828
Members
452,946
Latest member
JoseDavid

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