Compile Error: With From:= << Highlighted

J

JMay

Sub PrintSkipP1()
Dim sht As Worksheet

For Each sht In ActiveWindow.SelectedSheets
sht.PrintPreview From:=2, To:=4
Next sht

Set sht = Nothing
End Sub

WHY?
 
M

Mike H

Hi,

As far as I'm aware the only switches for .printpreview are True/False and
the correct syntax is

sht.PrintPreview (True)

What are you attempting to do with the switch you are using?

Mike
 
J

JMay

Thanks Mike,
Actually, I'm trying to create a Macro that will Skip the printing of my
Page 1 of my Active 4 page printout (print only 2,3 and 4). For testing I
always use the Preview option versus PrintOut (to save paper). Also - I
actually want the To:= to be To:=[Pages] representing print to the last
page (whatever number that is)...
Thanks,
Jim
 
M

Mike H

Hi,

I look to be corrected but I'm fairly sure you can only preview all pages.
printout is different you can do this

For Each sht In ActiveWindow.SelectedSheets
sht.Printout From:=2, To:=4
Next sht

Mike

JMay said:
Thanks Mike,
Actually, I'm trying to create a Macro that will Skip the printing of my
Page 1 of my Active 4 page printout (print only 2,3 and 4). For testing I
always use the Preview option versus PrintOut (to save paper). Also - I
actually want the To:= to be To:=[Pages] representing print to the last
page (whatever number that is)...
Thanks,
Jim


Mike H said:
Hi,

As far as I'm aware the only switches for .printpreview are True/False and
the correct syntax is

sht.PrintPreview (True)

What are you attempting to do with the switch you are using?

Mike
 
D

Dave Peterson

..printout has a preview parm:

sht.PrintOut preview:=True, From:=2, To:=999

(make 999 as big as you want to ensure that you got all the pages.)
Thanks Mike,
Actually, I'm trying to create a Macro that will Skip the printing of my
Page 1 of my Active 4 page printout (print only 2,3 and 4). For testing I
always use the Preview option versus PrintOut (to save paper). Also - I
actually want the To:= to be To:=[Pages] representing print to the last
page (whatever number that is)...
Thanks,
Jim

Mike H said:
Hi,

As far as I'm aware the only switches for .printpreview are True/False and
the correct syntax is

sht.PrintPreview (True)

What are you attempting to do with the switch you are using?

Mike
 
J

JMay

Final Code (seems a shame that we have to refer to Excel4Macro.... it get it
to work -- Is there a more current substitute?)
Tks Mike

Sub PrintSkipP1()
Dim sht As Worksheet
TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
For Each sht In ActiveWindow.SelectedSheets
sht.PrintOut From:=2, To:=TotPages
Next sht
Set sht = Nothing
End Sub

Mike H said:
Hi,

I look to be corrected but I'm fairly sure you can only preview all pages.
printout is different you can do this

For Each sht In ActiveWindow.SelectedSheets
sht.Printout From:=2, To:=4
Next sht

Mike

JMay said:
Thanks Mike,
Actually, I'm trying to create a Macro that will Skip the printing of my
Page 1 of my Active 4 page printout (print only 2,3 and 4). For testing I
always use the Preview option versus PrintOut (to save paper). Also - I
actually want the To:= to be To:=[Pages] representing print to the last
page (whatever number that is)...
Thanks,
Jim


Mike H said:
Hi,

As far as I'm aware the only switches for .printpreview are True/False and
the correct syntax is

sht.PrintPreview (True)

What are you attempting to do with the switch you are using?

Mike



:

Sub PrintSkipP1()
Dim sht As Worksheet

For Each sht In ActiveWindow.SelectedSheets
sht.PrintPreview From:=2, To:=4
Next sht

Set sht = Nothing
End Sub

WHY?
 
R

Ron de Bruin

Hi Dave

I believe this part To:=999 is not needed if I remember correct ?

The OP can use
sht.PrintOut preview:=True, From:=2


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


Dave Peterson said:
.printout has a preview parm:

sht.PrintOut preview:=True, From:=2, To:=999

(make 999 as big as you want to ensure that you got all the pages.)
Thanks Mike,
Actually, I'm trying to create a Macro that will Skip the printing of my
Page 1 of my Active 4 page printout (print only 2,3 and 4). For testing I
always use the Preview option versus PrintOut (to save paper). Also - I
actually want the To:= to be To:=[Pages] representing print to the last
page (whatever number that is)...
Thanks,
Jim

Mike H said:
Hi,

As far as I'm aware the only switches for .printpreview are True/False and
the correct syntax is

sht.PrintPreview (True)

What are you attempting to do with the switch you are using?

Mike



:

Sub PrintSkipP1()
Dim sht As Worksheet

For Each sht In ActiveWindow.SelectedSheets
sht.PrintPreview From:=2, To:=4
Next sht

Set sht = Nothing
End Sub

WHY?
 
J

JMay

Thanks Both Dave and Ron --
So my lastest code (see under last comm to Mike) with Q is solved
by "forgetting" the need for the To:= parameter?
Coooooooool !!!!!!!!!


Ron de Bruin said:
Hi Dave

I believe this part To:=999 is not needed if I remember correct ?

The OP can use
sht.PrintOut preview:=True, From:=2


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


Dave Peterson said:
.printout has a preview parm:

sht.PrintOut preview:=True, From:=2, To:=999

(make 999 as big as you want to ensure that you got all the pages.)
Thanks Mike,
Actually, I'm trying to create a Macro that will Skip the printing of my
Page 1 of my Active 4 page printout (print only 2,3 and 4). For testing I
always use the Preview option versus PrintOut (to save paper). Also - I
actually want the To:= to be To:=[Pages] representing print to the last
page (whatever number that is)...
Thanks,
Jim

:

Hi,

As far as I'm aware the only switches for .printpreview are True/False and
the correct syntax is

sht.PrintPreview (True)

What are you attempting to do with the switch you are using?

Mike



:

Sub PrintSkipP1()
Dim sht As Worksheet

For Each sht In ActiveWindow.SelectedSheets
sht.PrintPreview From:=2, To:=4
Next sht

Set sht = Nothing
End Sub

WHY?
 
R

Ron de Bruin

Is there a more current substitute

Not that I know of
I also use it here
http://www.rondebruin.nl/print.htm#not

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


JMay said:
Final Code (seems a shame that we have to refer to Excel4Macro.... it get it
to work -- Is there a more current substitute?)
Tks Mike

Sub PrintSkipP1()
Dim sht As Worksheet
TotPages = Application.ExecuteExcel4Macro("GET.DOCUMENT(50)")
For Each sht In ActiveWindow.SelectedSheets
sht.PrintOut From:=2, To:=TotPages
Next sht
Set sht = Nothing
End Sub

Mike H said:
Hi,

I look to be corrected but I'm fairly sure you can only preview all pages.
printout is different you can do this

For Each sht In ActiveWindow.SelectedSheets
sht.Printout From:=2, To:=4
Next sht

Mike

JMay said:
Thanks Mike,
Actually, I'm trying to create a Macro that will Skip the printing of my
Page 1 of my Active 4 page printout (print only 2,3 and 4). For testing I
always use the Preview option versus PrintOut (to save paper). Also - I
actually want the To:= to be To:=[Pages] representing print to the last
page (whatever number that is)...
Thanks,
Jim


:

Hi,

As far as I'm aware the only switches for .printpreview are True/False and
the correct syntax is

sht.PrintPreview (True)

What are you attempting to do with the switch you are using?

Mike



:

Sub PrintSkipP1()
Dim sht As Worksheet

For Each sht In ActiveWindow.SelectedSheets
sht.PrintPreview From:=2, To:=4
Next sht

Set sht = Nothing
End Sub

WHY?
 
D

Dave Peterson

And if you use .printout and add preview:=true, you'll be able to printpreview,
too.
Thanks Both Dave and Ron --
So my lastest code (see under last comm to Mike) with Q is solved
by "forgetting" the need for the To:= parameter?
Coooooooool !!!!!!!!!

Ron de Bruin said:
Hi Dave
(make 999 as big as you want to ensure that you got all the pages.)

I believe this part To:=999 is not needed if I remember correct ?

The OP can use
sht.PrintOut preview:=True, From:=2


--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


Dave Peterson said:
.printout has a preview parm:

sht.PrintOut preview:=True, From:=2, To:=999

(make 999 as big as you want to ensure that you got all the pages.)

JMay wrote:

Thanks Mike,
Actually, I'm trying to create a Macro that will Skip the printing of my
Page 1 of my Active 4 page printout (print only 2,3 and 4). For testing I
always use the Preview option versus PrintOut (to save paper). Also - I
actually want the To:= to be To:=[Pages] representing print to the last
page (whatever number that is)...
Thanks,
Jim

:

Hi,

As far as I'm aware the only switches for .printpreview are True/False and
the correct syntax is

sht.PrintPreview (True)

What are you attempting to do with the switch you are using?

Mike



:

Sub PrintSkipP1()
Dim sht As Worksheet

For Each sht In ActiveWindow.SelectedSheets
sht.PrintPreview From:=2, To:=4
Next sht

Set sht = Nothing
End Sub

WHY?
 

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

Top