?
Solved

Excel Macro Error when trying to print

Posted on 2011-09-27
5
Medium Priority
?
199 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 42

Accepted Solution

by:
dlmille earned 1000 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 42

Assisted Solution

by:dlmille
dlmille earned 1000 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 500 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 33

Assisted Solution

by:Rob Henson
Rob Henson earned 500 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

This code takes an Excel list of URL’s and adds a header titled “URL List”. It then searches through all URL’s in column “A”, looking for duplicates. When a duplicate is found, it is moved to the top of the list. The duplicate URL’s are then highlig…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

765 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