Unable to run macros...

  • Thread starter Marco Margaritelli
  • Start date
M

Marco Margaritelli

Using Win XP Pro (SP2) + Office 2003

After many years using the same worksheet containing the same macros, these
(ALL) have stopped working.
When I click the button that call the macro, Excel and I have to close it
with CTRL+ALT+DEL.

Thinking that was something wrong with the macro itself, I created a new
sheet with a very simple macro:

Here it is:
============================

Sub Button5_Click()
'
' Button5_Click Macro
' Macro recorded 9/6/2008 by Marco Margaritelli
'
'
Range("A1:B2").Select
Application.ActivePrinter = "Zebra LP2844ps on Ne00:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, ActivePrinter:= _
"Zebra LP2844ps on Ne00:", Collate:=True
End Sub

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

This print function worked when I was creating the macro, the I save it, and
clicked the Button just created that call for this macro and even this simple
script freezes everything, BUT if I manualy run this one from the MS Visual
Basic VBA "Run-F5" function it works, BUT NOT if I call it from the button
created to run this macro...
Kind of weird...

A few days ago I re-installed Office 2003 and the problem was solved...
Now it is happening again... I did NOT install any new software... I even
disable McAfee from Script Scanning and its "System Guard", just in case...

Everything else in Office 2003 seems to be working fine, even Excel it is
fine, the problem is ONLY the unability of running macros.
I need them!...
Any suggestions?

THANKS!
 
M

Marco Margaritelli

Barb,
thank you for your reply.

Nobody changed the name of the printer, as a matter of fact the macro works
(prints) when I do the recording of it... But id does not when I press the
button just created that invoke the same macro...
Also I created another one, simple as the previous one, using another
printer, with the exact same results.

ALSO: While waiting fro an answer, I created another button/macro, where I
recorded a simple "copy and paste" funcition (see below), and THIS WORKS JUST
FINE! (see script below)

I created a Third button/macro with a little more complicated function:
Sort column "A", containing just numbers from 1 to 20, "A to Z", copy it to
column "B" and sort it again "Z to A".
This one to works just fine...

So, the problem seems to be JUST when invoking the PRINT function for ANY
printer.
But all printer work fine, and as said, the macro performs fine when
creating it.
Is'nt this weird?

Looking forward to your help...
THANKS!

==========================================
Sub Button4_Click()
'
' Button4_Click Macro
' Macro recorded 9/6/2008 by Marco Margaritelli
'

'
Range("A1:C1").Select
Application.ActivePrinter = "HP LaserJet 5000 Series PCL6 on LPT1:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub
==========================================

Sub Button3_Click()
'
' Button3_Click Macro
' Macro recorded 9/6/2008 by Marco Margaritelli
'

'
Range("A1:C1").Select
Selection.Copy
Range("A3").Select
ActiveSheet.Paste
Range("A1").Select
End Sub

====================================
 
D

Don Guillett

To test your theory.
Add any printer you don't already have. You can't print to it but you can
printPREVIEW to it.
Also, try using a shape or button from the forms menu to assign your macro.
I never use command buttons.
 
M

Marco Margaritelli

Don:
Thank you for your hint. It worked:
I created a macro as you said, and it worked.
The I opened my previous one that suddently is giving me trouble, I added
the "Preview:=True," statement in the macro line that now reads:

==================
Sub Sheet2_Button1_Click()
'
' Sheet2_Button1_Click Macro
' Macro recorded 9/6/2008 by Marco Margaritelli
'

'
Range("A1:B14").Select
ActiveSheet.PageSetup.PrintArea = "$A$1:$B$14"
Application.ActivePrinter = "Zebra LP2844ps on Ne00:"
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Preview:=True, _
ActivePrinter:="Zebra LP2844ps on Ne00:", Collate:=True
End Sub=========================

And NOW IT WORKS! Although now is no longer automatic as I have to manually
click the "Print" button from the preview screen, to print the page and allow
the macro to continue its routine...

This partially solve my problem, but REALLY I would like to understand what
it is happening, and solve the matter completely, otherwise my macros (that I
mostly use to print mailing labels and letters) will be kind of handicapped,
as I will have to click the Print button from the preview every time to let
it continue...

What do you think could be?
Why prints if FIRST goes to the Print Preview the macro works and NOT if
just goes to the Print directly?

By the way, I mistakenly said that I was using a "Command" button, but
really the button I use are from the Form menu...

THANK YOU!!!
Looking forward to a kind reply...
 
D

Dave Peterson

This is just a SWAG...

Maybe it's a network problem.

Can you disconnect the printer and then reconnect the printer--then as fast as
you can, click the button that failed before.

I'm thinking that as long as your pc can find the printer on the network, things
print fine. (Good coincidence for the manual printing (while recording the
macro) works fine--but bad coincidence when you click the button a little
later????).

And just to add to Don's suggestion, I'd install a local printer driver (not a
network driver) to test the print preview.

If you find the solution, please post back.
 
B

Barb Reinhardt

I'm guessing you don't need this line at all. Comment it out and see what
happens.

Application.ActivePrinter = "Zebra LP2844ps on Ne00:"
 
M

Marco Margaritelli

Barb:
Thank you for your reply.
Well, I removed the line: Application.ActivePrinter = "Zebra LP2844ps on
Ne00:"
but still the same problem: No printing and everything frezes...

Furthermore, I really need this line because the Zebra LP2844 is NOT my
default printer. You see this is a simple macro that prints an Address Label
 

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