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

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
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,223,234
Messages
6,170,891
Members
452,366
Latest member
TePunaBloke

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