Solved

Excel Macro Error when trying to print

Posted on 2011-09-27
5
196 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 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 42

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 33

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Convert between Excel file formats (.XLS, .XLSX, .XLSM) with/without macro option David Miller (dlmille) Intro Over this past Fall, I've had the opportunity to see several similar requests and have developed a couple related solutions associate…
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.

732 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