Complie Error- Argument not optional

R

Roberta

Recorded a macro to open a workbook then to preview then change settings in
page setup and when I run it I get the Compile Error.

Here's the area with an issue: It has no numbers for all but one margin ().
Seems like margin setting isn't recording. BottomMargin is highlighted.

ActiveWindow.SelectedSheets.PrintPreview

ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight, RegionIndex:=1

With ActiveSheet.PageSetup

.LeftMargin = Application.InchesToPoints(0.29)

.RightMargin = Application.InchesToPoints()

.TopMargin = Application.InchesToPoints()

.BottomMargin = Application.InchesToPoints()

.HeaderMargin = Application.InchesToPoints()

.FooterMargin = Application.InchesToPoints()

.Zoom = False

.FitToPagesWide = 1

.FitToPagesTall = 1

.PrintErrors = 13292

End With
 
R

Roberta

Correction:

InchestoPoint is selected on the line for Left Margin not Bottom Margin.
 
J

Jim Rech

You'll have to supply a number to the InchesToPoints method or delete those
lines. I don't know why you didn't get a number in the method when you
recorded (I always do) but you have to supply it anyway.
 
R

Roberta

Even when I supply the inches it doesn't work and when I go back and look at
the VBA the numbers are not in the bracket.

I went to another PC and recorded and ran the same macro and its works but
form the one machine the recorded macro gets an error no matter whcih
workbook it is ran from. Any ideas?
 
J

Jim Rech

Any ideas?

Not really. When one machine behaves differently than another you have to
ask how it is different. In this case since it involves printing you think
of the printer driver. But how that could cause this problem is beyond me.

--
Jim
| Even when I supply the inches it doesn't work and when I go back and look
at
| the VBA the numbers are not in the bracket.
|
| I went to another PC and recorded and ran the same macro and its works but
| form the one machine the recorded macro gets an error no matter whcih
| workbook it is ran from. Any ideas?
|
| "Jim Rech" wrote:
|
| > You'll have to supply a number to the InchesToPoints method or delete
those
| > lines. I don't know why you didn't get a number in the method when you
| > recorded (I always do) but you have to supply it anyway.
| >
| > --
| > Jim
| > | > > Correction:
| > >
| > > InchestoPoint is selected on the line for Left Margin not Bottom
Margin.
| > >
| > > "Roberta" wrote:
| > >
| > >> Recorded a macro to open a workbook then to preview then change
settings
| > >> in
| > >> page setup and when I run it I get the Compile Error.
| > >>
| > >> Here's the area with an issue: It has no numbers for all but one
margin
| > >> ().
| > >> Seems like margin setting isn't recording. BottomMargin is
highlighted.
| > >>
| > >> ActiveWindow.SelectedSheets.PrintPreview
| > >>
| > >> ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight,
| > >> RegionIndex:=1
| > >>
| > >> With ActiveSheet.PageSetup
| > >>
| > >> .LeftMargin = Application.InchesToPoints(0.29)
| > >>
| > >> .RightMargin = Application.InchesToPoints()
| > >>
| > >> .TopMargin = Application.InchesToPoints()
| > >>
| > >> .BottomMargin = Application.InchesToPoints()
| > >>
| > >> .HeaderMargin = Application.InchesToPoints()
| > >>
| > >> .FooterMargin = Application.InchesToPoints()
| > >>
| > >> .Zoom = False
| > >>
| > >> .FitToPagesWide = 1
| > >>
| > >> .FitToPagesTall = 1
| > >>
| > >> .PrintErrors = 13292
| > >>
| > >> End With
| > >>
| > >>
| >
| >
| >
 
R

Roberta

Well I'm at a lost.....

Jim Rech said:
Not really. When one machine behaves differently than another you have to
ask how it is different. In this case since it involves printing you think
of the printer driver. But how that could cause this problem is beyond me.

--
Jim
| Even when I supply the inches it doesn't work and when I go back and look
at
| the VBA the numbers are not in the bracket.
|
| I went to another PC and recorded and ran the same macro and its works but
| form the one machine the recorded macro gets an error no matter whcih
| workbook it is ran from. Any ideas?
|
| "Jim Rech" wrote:
|
| > You'll have to supply a number to the InchesToPoints method or delete
those
| > lines. I don't know why you didn't get a number in the method when you
| > recorded (I always do) but you have to supply it anyway.
| >
| > --
| > Jim
| > | > > Correction:
| > >
| > > InchestoPoint is selected on the line for Left Margin not Bottom
Margin.
| > >
| > > "Roberta" wrote:
| > >
| > >> Recorded a macro to open a workbook then to preview then change
settings
| > >> in
| > >> page setup and when I run it I get the Compile Error.
| > >>
| > >> Here's the area with an issue: It has no numbers for all but one
margin
| > >> ().
| > >> Seems like margin setting isn't recording. BottomMargin is
highlighted.
| > >>
| > >> ActiveWindow.SelectedSheets.PrintPreview
| > >>
| > >> ActiveSheet.VPageBreaks(1).DragOff Direction:=xlToRight,
| > >> RegionIndex:=1
| > >>
| > >> With ActiveSheet.PageSetup
| > >>
| > >> .LeftMargin = Application.InchesToPoints(0.29)
| > >>
| > >> .RightMargin = Application.InchesToPoints()
| > >>
| > >> .TopMargin = Application.InchesToPoints()
| > >>
| > >> .BottomMargin = Application.InchesToPoints()
| > >>
| > >> .HeaderMargin = Application.InchesToPoints()
| > >>
| > >> .FooterMargin = Application.InchesToPoints()
| > >>
| > >> .Zoom = False
| > >>
| > >> .FitToPagesWide = 1
| > >>
| > >> .FitToPagesTall = 1
| > >>
| > >> .PrintErrors = 13292
| > >>
| > >> End With
| > >>
| > >>
| >
| >
| >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Print area - selection 4
Page setup too slow 2
Setting Print Range 2
Printing Setup help 9
Define a Variable 1
Problems With Page Breaks 5
Slow PageSetup macro 3
Slow Macro - Formatting Macro 1

Top