Solved

Excel Macro Error when trying to print

Posted on 2011-09-27
5
195 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 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Getting rid of #VALUE! 7 23
V-Lookup 11 21
Index Match Array? 5 40
Slow calculation 2 21
Approximate matching with VLOOKUP and MATCH seems to me to be a greatly under-used technique, and one which is vital for getting good performance out of large lookups. Until recently I would always have advised using an exact match for simplicity an…
Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
This Micro Tutorial demonstrates how to create Excel charts: column, area, line, bar, and scatter charts. Formatting tips are provided as well.

820 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