ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Simple Macro freezes the whole Excel and PC! (https://www.excelbanter.com/excel-programming/429482-simple-macro-freezes-whole-excel-pc.html)

Marco Margaritelli

Simple Macro freezes the whole Excel and PC!
 
I created (recorded) a very simple macro that "Select an area", "Select a
printer", and "Print".
It works the first time, (while recording it), but when I Play It again, It
FREEZES Excel and the whole PC!

The SAME Macro works just fine just changing the "Preview:=" statement from
"False" to "true".

===============================================
THIS ONE BELOW WORKS JUST FINE!!!
===============================================

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli
'

'
Range("B3:C5").Select
ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True, Preview:=True
Range("E3").Select
End Sub


===============================================
THIS ONE BELOW DOES NOT WORK... IT FREEZE UP EXCEL AND EVERYTHING ELSE IN
THE PC!
===============================================

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli
'

'
Range("B3:C5").Select
ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True, Preview:=False
Range("E3").Select
End Sub

================================================== =

This happen in ALL Excel Macros I created and that have been working Just
fine for years!
I never had this problem since a few months ago (I believe after a MS
Security Update...).

I hope someone could clear this "MISTERY!"

THANKS!



JLGWhiz[_2_]

Simple Macro freezes the whole Excel and PC!
 
I believe you only have one sheet to print. Try this.

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli


'

ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveSheet.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True,
Preview:=False
Range("E3").Select
End Sub






"Marco Margaritelli" wrote in
message ...
I created (recorded) a very simple macro that "Select an area", "Select a
printer", and "Print".
It works the first time, (while recording it), but when I Play It again,
It
FREEZES Excel and the whole PC!

The SAME Macro works just fine just changing the "Preview:=" statement
from
"False" to "true".

===============================================
THIS ONE BELOW WORKS JUST FINE!!!
===============================================

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli
'

'
Range("B3:C5").Select
ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True,
Preview:=True
Range("E3").Select
End Sub


===============================================
THIS ONE BELOW DOES NOT WORK... IT FREEZE UP EXCEL AND EVERYTHING ELSE IN
THE PC!
===============================================

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli
'

'
Range("B3:C5").Select
ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True,
Preview:=False
Range("E3").Select
End Sub

================================================== =

This happen in ALL Excel Macros I created and that have been working Just
fine for years!
I never had this problem since a few months ago (I believe after a MS
Security Update...).

I hope someone could clear this "MISTERY!"

THANKS!





Don Guillett

Simple Macro freezes the whole Excel and PC!
 
Should do it

Sub printrng()
Application.ActivePrinter = _
"DYMO LabelWriter Twin Turbo on Ne04:"
ActiveSheet.Range("b3:c65").PrintOut
End Sub

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Marco Margaritelli" wrote in
message ...
I created (recorded) a very simple macro that "Select an area", "Select a
printer", and "Print".
It works the first time, (while recording it), but when I Play It again,
It
FREEZES Excel and the whole PC!

The SAME Macro works just fine just changing the "Preview:=" statement
from
"False" to "true".

===============================================
THIS ONE BELOW WORKS JUST FINE!!!
===============================================

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli
'

'
Range("B3:C5").Select
ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True,
Preview:=True
Range("E3").Select
End Sub


===============================================
THIS ONE BELOW DOES NOT WORK... IT FREEZE UP EXCEL AND EVERYTHING ELSE IN
THE PC!
===============================================

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli
'

'
Range("B3:C5").Select
ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True,
Preview:=False
Range("E3").Select
End Sub

================================================== =

This happen in ALL Excel Macros I created and that have been working Just
fine for years!
I never had this problem since a few months ago (I believe after a MS
Security Update...).

I hope someone could clear this "MISTERY!"

THANKS!




Marco Margaritelli

Simple Macro freezes the whole Excel and PC!
 
Thank you!
It worked!

I was just wondering WHY that happens...
After all I did NOT wrote myself the macro, but Excel did it automatically
as I "recorded" the macro...

Unfortunately from now on when I record a macro like this to print something
(which I do very often), I will have to REPLACE the code wrote duiring the
"recording" with the one kindly supplied to me by you...

This is annoying Microsoft!

"JLGWhiz" wrote:

I believe you only have one sheet to print. Try this.

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli


'

ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveSheet.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True,
Preview:=False
Range("E3").Select
End Sub






"Marco Margaritelli" wrote in
message ...
I created (recorded) a very simple macro that "Select an area", "Select a
printer", and "Print".
It works the first time, (while recording it), but when I Play It again,
It
FREEZES Excel and the whole PC!

The SAME Macro works just fine just changing the "Preview:=" statement
from
"False" to "true".

===============================================
THIS ONE BELOW WORKS JUST FINE!!!
===============================================

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli
'

'
Range("B3:C5").Select
ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True,
Preview:=True
Range("E3").Select
End Sub


===============================================
THIS ONE BELOW DOES NOT WORK... IT FREEZE UP EXCEL AND EVERYTHING ELSE IN
THE PC!
===============================================

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli
'

'
Range("B3:C5").Select
ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True,
Preview:=False
Range("E3").Select
End Sub

================================================== =

This happen in ALL Excel Macros I created and that have been working Just
fine for years!
I never had this problem since a few months ago (I believe after a MS
Security Update...).

I hope someone could clear this "MISTERY!"

THANKS!






Don Guillett

Simple Macro freezes the whole Excel and PC!
 
Did you see my simpler macro?

--
Don Guillett
Microsoft MVP Excel
SalesAid Software

"Marco Margaritelli" wrote in
message ...
Thank you!
It worked!

I was just wondering WHY that happens...
After all I did NOT wrote myself the macro, but Excel did it automatically
as I "recorded" the macro...

Unfortunately from now on when I record a macro like this to print
something
(which I do very often), I will have to REPLACE the code wrote duiring the
"recording" with the one kindly supplied to me by you...

This is annoying Microsoft!

"JLGWhiz" wrote:

I believe you only have one sheet to print. Try this.

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli


'

ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveSheet.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True,
Preview:=False
Range("E3").Select
End Sub






"Marco Margaritelli" wrote
in
message ...
I created (recorded) a very simple macro that "Select an area", "Select
a
printer", and "Print".
It works the first time, (while recording it), but when I Play It
again,
It
FREEZES Excel and the whole PC!

The SAME Macro works just fine just changing the "Preview:=" statement
from
"False" to "true".

===============================================
THIS ONE BELOW WORKS JUST FINE!!!
===============================================

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli
'

'
Range("B3:C5").Select
ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True,
Preview:=True
Range("E3").Select
End Sub


===============================================
THIS ONE BELOW DOES NOT WORK... IT FREEZE UP EXCEL AND EVERYTHING ELSE
IN
THE PC!
===============================================

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli
'

'
Range("B3:C5").Select
ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True,
Preview:=False
Range("E3").Select
End Sub

================================================== =

This happen in ALL Excel Macros I created and that have been working
Just
fine for years!
I never had this problem since a few months ago (I believe after a MS
Security Update...).

I hope someone could clear this "MISTERY!"

THANKS!







JLGWhiz[_2_]

Simple Macro freezes the whole Excel and PC!
 
I am not really sure, but I believe it is related to the SelectedSheets part
of the code. I never use that paticular code. I try to write it so that it
specifies the exact sheet or sheets that I want to print. If you learn to
edit the recorded macros to take out the Select and Selected you will have
much more efficient code. Instead of:

Range("A1").Select
Selection.Copy

Just write:

Range("A1").Copy

It takes a while to get in the habit of using the shorter syntax, but it
does make better looking and easier to read code.


"Marco Margaritelli" wrote in
message ...
Thank you!
It worked!

I was just wondering WHY that happens...
After all I did NOT wrote myself the macro, but Excel did it automatically
as I "recorded" the macro...

Unfortunately from now on when I record a macro like this to print
something
(which I do very often), I will have to REPLACE the code wrote duiring the
"recording" with the one kindly supplied to me by you...

This is annoying Microsoft!

"JLGWhiz" wrote:

I believe you only have one sheet to print. Try this.

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli


'

ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveSheet.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True,
Preview:=False
Range("E3").Select
End Sub






"Marco Margaritelli" wrote
in
message ...
I created (recorded) a very simple macro that "Select an area", "Select
a
printer", and "Print".
It works the first time, (while recording it), but when I Play It
again,
It
FREEZES Excel and the whole PC!

The SAME Macro works just fine just changing the "Preview:=" statement
from
"False" to "true".

===============================================
THIS ONE BELOW WORKS JUST FINE!!!
===============================================

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli
'

'
Range("B3:C5").Select
ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True,
Preview:=True
Range("E3").Select
End Sub


===============================================
THIS ONE BELOW DOES NOT WORK... IT FREEZE UP EXCEL AND EVERYTHING ELSE
IN
THE PC!
===============================================

Sub Button8_Click()
'
' Button8_Click Macro
' Macro recorded 6/6/2009 by Marco Margaritelli
'

'
Range("B3:C5").Select
ActiveSheet.PageSetup.PrintArea = "$B$3:$C$5"
Application.ActivePrinter = "DYMO LabelWriter Twin Turbo on Ne04:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"DYMO LabelWriter Twin Turbo on Ne04:", Collate:=True,
Preview:=False
Range("E3").Select
End Sub

================================================== =

This happen in ALL Excel Macros I created and that have been working
Just
fine for years!
I never had this problem since a few months ago (I believe after a MS
Security Update...).

I hope someone could clear this "MISTERY!"

THANKS!









All times are GMT +1. The time now is 09:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com