Excel Print Routine Help

Apr 04, 2009 19 Replies

About six months ago I asked in this ng about a routine to put into Excel to skip any page that didn't have a character of some sort in a specific cell.



Some kind person wrote up a routine for me that started off:



Sub selprint() Dim i As Integer Dim currentsheet As Worksheet



For i = 1 To ActiveWorkbook.Worksheets.Count


I have tried everything I know to insert that routine into Excel and have failed miserably. WOuld that kind person please lead me by the hand through the installation and use stuff?



Many thanks,



Jim


"It is the mark of an educated mind to be able to entertain a thought without accepting it." --Aristotle

Tools->Macro->Visual basic editor Then you should select ThisWorkbook and past your code

It should work then.

Cheers

>

I'm sorry, sir, and I appreciate the help, but there is no "ThisWorkbook" command in Tools->Macro->Visual Basic Editor. That was the instruction that somebody gave me last time and I've been on and off fiddling with it for about six months.

Can you be a bit more specific (Excel 2003)?

Jim

Sorry maybe I was not clear.

To open the VBA Editor, Tools->Macro->Visual basic editor Then in the VBA editor select 'ThisWorkbook' in the Left pane. This applies to Office 2003. As mentioned Alt+F11 is the short cut to the VBA editor.

Cheers

Martin & Tom

There is no "Left Pane" when I open up the VB editor. THere is a gray screen and two lines of commands along the top. THe top one is the usual "File Edit View ..." and below that there is a toolbar with icons. No Left Pane.

Jim

In VBA select View->ProjectExplorer. This is the left pane we are referencing. its usually shown by default. It'll Show VBAProject (Book1)... and the list of Sheets(Sheet1 Sheet2....) and ThisWorkbook. Double click on ThisWorkbook and the code window will display.

Cheers

FOUND IT. GOT IT. INSTALLED IT.

It doesn't do anything. WHere do we go from here? I used both characters (Y) and numerical characters (1.00) in the target cell and it still printed that page quite nicely. I used null ("") in my IF statement for pages I didn't want to print and it printed THAT page quite nicely as well.

Jim

> In VBA select View->ProjectExplorer. This is the left pane we are > referencing. > its usually shown by default. > It'll Show VBAProject (Book1)... and the list of Sheets(Sheet1 Sheet2....) > and ThisWorkbook. > Double click on ThisWorkbook and the code window will display. > > Cheers > > >

Can you post the code?

Cheers

Sure, here you go:

Sub selprint() Dim i As Integer Dim currentsheet As Worksheet

For i = 1 To ActiveWorkbook.Worksheets.Count Set currentsheet = ActiveWorkbook.Worksheets(i) Worksheets(i).Activate 'Skip empty sheets and hidden sheets If Application.CountA(currentsheet.Cells) 0 And currentsheet.Visible Then 'change the hard-coded cell here if not F52 If (Not IsNull(Range("F52"))) And (Range("F52").Value 0) Then 'un-comment the next line when debugging completed ' ActiveSheet.PrintOut 'add comment at start of next line when debugging completed ActiveSheet.PrintPreview End If End If Next i End Sub

Jim

Not sure, but try an lparen "(" just after "if" and an rparen ")" just before "then" if you would.

If you want an excel NG please setup your newsreader to _also_ point directly at

news.microsoft.com

and pick up one there. It is read by many MS support staffers, MVPS, and other experts.

Except that several posts have been made there already, of which none have been answered.

I've seen nothing about this thread on microsoft.public.excel. Always very active.

RL

I posted to microsoft.public.excel.programming and microsoft.public.excel.worksheet.functions without getting a single response. However, Archimedes posted me code yesterday that works just like I want it to, although it wasn't the way I was thinking about it to start with.

I'd sort of like to take the code line by line and see if I can work my way through it to understand a little bit more than when I started. Here is the whole code and I'll annotate it with '* to indicate that it is MY annotation and not the author's. I'll do that over in the newsgroup microsoft.public.excel.programming. Thanks to all for the help.

"It is the mark of an educated mind to be able to entertain a thought without accepting it." --Aristotle > I've seen nothing about this thread on microsoft.public.excel. Always > very active. > > RL

Jim, Could you E-mail me a copy? Thanks!

...Jim Thompson

| James E.Thompson, P.E. | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine Sometimes I even put it in the food

-- "It is the mark of an educated mind to be able to entertain a thought without accepting it." --Aristotle

"Jim Thompson" wrote in message news: snipped-for-privacy@4ax.com...

Just the code or the annotation too? Either one you wish. I'll be back home Sunday.

Jim

With the annotation. I'm just now learning to use Excel's more advanced features myself... trying my hand at behavioral modeling of systems... after years of trivial use ;-)

...Jim Thompson

| James E.Thompson, P.E. | mens | | Analog Innovations, Inc. | et | | Analog/Mixed-Signal ASIC's and Discrete Systems | manus | | Phoenix, Arizona 85048 Skype: Contacts Only | | | Voice:(480)460-2350 Fax: Available upon request | Brass Rat | | E-mail Icon at http://www.analog-innovations.com | 1962 | I love to cook with wine Sometimes I even put it in the food

The power of all Microsoft Office applications is their VBA interface. It essentially is Visual BASIC, pretty easy. They did throw a slight curve ball going from 2000 to 2007 but the references are now ! instead of . noted.

Idiot. 2003 came between that.

Never heard of a range. 2000 to 2007 would include Office XP, and Office

2003.

You're obviously a Microsoft lapdog.

DimBulb certainly is a M$ lapdog, though not housebroken.

Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required