Solved

Excel Macro Error when trying to print

Posted on 2011-09-27
5
192 Views
Last Modified: 2012-05-12
I have an excel sheet and have created a Macro to do the following 3 steps:
1. Print
2. Save as XLSX to a USB
3. Save as CSV to a USB

The macro works great by either pressing the shortcut key defined for the macro, or by selecting View > Macros > View Macros > Run.

I have tried to create a button on the screen to run this macro - Developer > Insert > Button (under form controls). Then when prompted, select the macro that I have already created.

Then when I try run this macro via the button, it always fails with the following error
 macro error1
If I click Debug, I see the following:
 Macro Error 2
Not sure why this would only happen when attaching the Macro to a button. It's running the same command.
0
Comment
Question by:Mayogroup
5 Comments
 
LVL 41

Accepted Solution

by:
dlmille earned 250 total points
ID: 36714966
Can you just ensure one sheet is selected, then test from your control sequence/or developer's menu?  Then, assuming that works of course, try it from your button?

Do you get the same error?

Dave
0
 
LVL 41

Assisted Solution

by:dlmille
dlmille earned 250 total points
ID: 36714970
Also, do you have any dialog boxes or userforms up when you run this macro?  There is a known bug with this error, if that is the case.

Dave
0
 
LVL 1

Assisted Solution

by:VictorBraga
VictorBraga earned 125 total points
ID: 36716363
I believe this is not the case, but IgnorePrintAreas gave me an error while trying to reproduce this on Excel 2003.

You could remove this option and see if it works. By default, Excel doesn't ignore print areas.
0
 

Author Comment

by:Mayogroup
ID: 36716420
Also forgot to mention, this is in Excel 2010.
0
 
LVL 32

Assisted Solution

by:Rob Henson
Rob Henson earned 125 total points
ID: 36816680
Have you tried drawing a Basic Shape button and assigning the macro to that instead?

I am wondering if by using a FormControl button, the system is thinking that there is a Form open and therefore doing as Dave mentioned earlier with the 'known bug'.

Thanks
Rob H
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

A little background as to how I came to I design this code: Around 5 years ago I designed an add-in that formatted Excel files to a corporate standard, applying different cell colours and font type depending on whether the cells contained inputs,…
This article will guide you to convert a grid from a picture into Excel format using Microsoft OneNote and no other 3rd party application.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now