Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  Advanced Search
  HOME    TRACKER    Excel


VBA Code For Printing

What I want to do is print a specific worksheet from a specific workbook based on data entered in text boxes. One text box would provide the workbook name and the other text box would provide the worksheet within the specified workbook. All the user would have to do is enter the workbook and worksheet names and then press a button to print. I currently have created a separate workbook with just a userform that contains a print button and two text boxes.

View Complete Thread with Replies

Sponsored Links:

Related Forum Messages:
Code For Printing
I am using excel 2000

From this and other forums I have found and adapted 2 bits of code as follows

The code below is used to print the sheets in a workbook in reverse order eg sheet 78, sheet 77, sheet 76 etc.....

View Replies!   View Related
VBA Code To Cancel Printing
I have a code that prepares my spreadsheet and then prints out around 6 different sheets when all is said and done. The prints are not together in the code. I was wondering if there is something that I can add at the beginning of the code to ask the user IF they want a Printout. If they answer Yes then they get printouts of the 6 or so sheets and if they answer No then the code will run but no printouts occur???

I have play3ed around a bit and implemented the following in one of my codes but this one only has 1 sheet that prints out.

'Checks to see if this is a corrected Deposit in which case Depositor probably has a Verification sheet already printed

If Sheets("Input Sheet").CheckBox5 = True Then

Answer = MsgBox("It's seems that this Verification sheet was already printed once. Do the Corrections you have made require you to print another one?" & vbCr & vbCr & "If you reuire the Verification sheet to print again the please click YES otherwise click No.", vbYesNo, "PRINT Out Required???")

If Answer = vbYes Then

ActiveSheet.Unprotect "unlock"
ActiveWindow.ScrollColumn = 1.........

View Replies!   View Related
Vba Code For Classified Printing
i have in sheet1 the names of the students and their marks and the finall results (pass ; fail ; comp)

i bring this data to the student certificate in sheet2 using lookup so when i change the number in h1 (the referance cell) the data ini the certificate will change , and i can print the certificate for every students put it is hard to change it manualy and print so i made this code that helps me to print the whole certicates by clicking the button
this the -

Sub printall()
Dim i As Integer
For i = 1 To 49
Range("h1").Value = i
ActiveWindow.SelectedSheets.PrintOut Copies:=1, Collate:=True
End Sub
now i need anew code to print only the (pass)results students , and one for the failed students certificates

View Replies!   View Related
Code For Printing Multiple Charts
I have a workbook with a chart on a worksheet called Area Report

There are 10 areas in total A - J, to view a particular area cell I2 is validated to only accept entries A - J which represent the Areas, selecting a particular area updates the chart for that area

Is it possible to have a macro that will print all 10 Area Reports, I tried to do it using the Record Macro function, the code was as follows .......

View Replies!   View Related
Code For Printing Particular Rows And Columns
I have a worksheet that I use to track my clients and their meal selections over a five day week. Col A is their name, B is their shift (am or pm) C is their table number, D is whether they will attend that day (yes or no) and E is their meal choice (a b or c) Columns D & E repeat the same information for each day Mon-Fri.

I would like to have a print button so that on a daily basis I can print the clients name and thier meal selection (only those those who have a yes for that day) separating AM shift from PM and then grouping them by their table number rather than alphabetical order.

View Replies!   View Related
VBA Code For Printing Variable Print Ranges
I am trying to write VBA code that will print a print range that is presented in cell F3 on a "Reports" worksheet. The content of F3 will change depending on how many reports the user selects to print. For example, he could select one, two, three reports etc - up to twelve. The cell ranges of each report are named (e.g. Report1, Report2 etc) so that if the user selects to print Reports 1 and 2, the contents of cell F3 are "Report1,Report2". If I replace WhatToPrint with "Report1,Report2" the print macro works.

Sub Macro2()
Dim WhatToPrint As String
WhatToPrint = Sheets("Reports").Cells(3, 6).Value
'sets the variable to equal the contents of cell D3 which contains the formula
'summarising the print ranges I want to print
Sheets("Reports").Cells(3, 6).Select
ActiveCell.FormulaR1C1 = WhatToPrint
' pastes the variable in cell F3 - just to check that it looks like I want it to
Sheets("Reports").PageSetup.PrintArea = WhatToPrint
'uses the variable to set print area - this is where it fails!
'if you replace the variable with the contents of cell F3 the macro will work
End Sub

View Replies!   View Related
VB Code/Macro Printing With Page End Pulled From Workbook
I have a worksheet that changes in length. There is a formula that calculates how many pages the sheet will be. The also is a print button on the sheet that will print a coversheet "Sheets("Title")" and then it is supposed to print the data on the second sheet. Below the code I have so far... I know I am missing something, but knowing very little about macros I just can't seem to figure it out.

View Replies!   View Related
Printing Code - Print Everything Down The Sheet Until It Sees A Blank In Col A
I want to have code that will print everything down the sheet until it sees a blank in column A. I have included the code i am trying but it keeps giving me errors.

View Replies!   View Related
Printing / Not Printing Ranges Based On Cell Contents
I have a report that is generated from a manufacturing process that looks like the example below. the report is 40 pages long when all the data is printed. i am looking for a way to only print this range if a dimension is "out of tolerance". if the dimension is within tolerance, there is always the "garbage" text of plus and minus. if every row is "within tolerance" in the range the cells in the OutTol column would all contain the "garbage" text but it will not always be identical. so, in summary, actual OutTol values = print and all "garbage" = not printed.


View Replies!   View Related
Printing One Page Grayscale And One Page Color With Code
I have a report that I use and right now I have a command button that prints the report x2. What I would like to do is to have it print one in color and one in grayscale. I could do this I think with two different buttons, but I would like to utilize just one. I tried creating a macro but it did not pick up the fact that I changed the properties to black and white.

View Replies!   View Related
2002 Code V 97 Code: Add A Small Workbook Open Event Code Which Works For Me But Debugs For The Others
I use excel 2002 but some of my office are on 97, i want to add a small workbook open event code which works for me but debugs for the others?? The code is basically, go to a tab, on that tab and that range sort..

View Replies!   View Related
Cracked Vb Code: Prevent People From Accesing The Code I Protected The Code Blocking It From Visualization
I've developed a little software using Excel Macros & VB. To prevent people from accesing the code I protected the code blocking it from visualization. It seems not enough as an acquaintance of a friend cracked it in 25 minutes. Or so he says. So I'd like to know if there is a better way to protect the font code.

View Replies!   View Related
Printing Macro ...
I have a workbook that has a print button on it. The print button macro prints many tabs on the workbook. But, on ONE of the tabs, it inserts information from a range of cells, prints, goes to the next cell in that range and prints, until complete.

The problem I'm having is this: When there is only ONE cell in that range that has information in it, it gets stuck in a continuous loop and prints a ton of blank pages.

Here's my code for this portion of the macro:

View Replies!   View Related
Printing Of PDF-files
Is it possible to print a pdf file from excel ?

I am making a list with pdf files that are on my hdd. I want to be able to select them and then send them to the printer.

(Yes I know it can be easily done from within the windows explorer by selecting and right-clicking, but my excel-file has to be able to do more than that )

View Replies!   View Related
Printing Tabs
i have included an example spreadsheet, hopefully someone can help me

i want a print button that when pressed with always print 'tab 1' and will print 'tab 2 3 4 etc... if a certain cell in 'tab 1' is greater than zero

please see my example spreadsheet and hopefully my problem will become clear if ive not explained myself very well.

View Replies!   View Related
Printing Pdf Files
We have a set of documents, all pdf files, residing in a network server. The shipping personnel will have a Laserjet 8150 ND (also on the network) to print the document they need at the time of shipment, for a specific product (the pdf files are actually User's Manuals for various products we sell).

We would like to create an Excel form, listing those documents, with a selection method to indicate which document is to be printed and how many copies. Then clicking on a "PRINT" button will send a command to the printer to print the desired manual.

I searched the forum threads and noticed that the subject mostly deals with printing TO pdf, whereas my need is to print pdf FROM Excel, but no such a command exists.

View Replies!   View Related
Printing Locks Up
I have a workbook that contains several macros and many formulas. It
works beautifully until I try to print or do a print preview. Then it locks
up excel and I have to restart. Any ideas about what is causing this?

View Replies!   View Related
Printing To PDF From Macro
I have tried to record the steps in a macro that are involved in printing a worksheet to a PDF. It recorded everything up to and including hte printer selection. However, it did not record the filename dialog box actions and beyond.

I have Adobe Acrobat 8 and Excel 2003.

View Replies!   View Related
Printing Macro
I have a table which I wish to print out, however I wish to print two copies of this table, one with only the rows which contain "AM" in column X, and one with the rows that contain "PM" in column X. There is also another complication in that several rows on the spreadsheet, containing data in column X, are hidden. The print range is everything between A3 & AG120.

I tried using a filter but found it unhid all the hidden rows and printed them out which I don't want.

View Replies!   View Related
Events Before Printing
I have early made a macro that will change some of the cells before printing and then changing back again to initional state after the print out.

But now I have to do let people also print a copy a regular way, without the macro I made before. But if they go through the regular way iof printing I would like to insert at header in red color, to notify them that this is just a preview and not the way to print. And here we come to the problem ....

View Replies!   View Related
Printing Up To End Of List Only
I have a form of 1000 lines and up to Column BM wide. Instead of printing the entire 1000 lines out which equates to 22 A4 pages (and a waste). How do I get Excel (03 & 08) to check from cell W12 to Cell W1000 and find the last entry in that col, and then print only up to that row. (Any method I will be extremely grateful for)

View Replies!   View Related
Repetitive Printing
I'm an entry level Excel user who is looking for a spread sheet to print multiple pages for tagging pallets in a warehouse. The pallets will contain the address of the customer and the number the pallet is.

Example 30 pallets would be
1 of 30 then print
2 0f 30 then print
3 of 30 then print

how I can put in a varible pallet total and have it print the all sheets up to the given number?

View Replies!   View Related
Printing Certain Columns
I have a spreadsheet that the Print range is A1:E265.
I want to know if I can print this range without Column C.

View Replies!   View Related
Automate PDF Printing
I have Adobe 6 and would like to automate the printing of Worksheets to PDFs using coding.

I want to control the location of the output i.e. specific directory. I can do this manually by selecting File...Print Select the Adobe PDF printer....go into options and deselect view PDF results. On printing I then get asked to soecify a location and all works fine....but how can I do this in code.

Unfortunately it also appears that when you restart Excel, the printer properties for the Adobe PDF printer are reset.

How can I code in the change in properties so that I can fully automise this task?

View Replies!   View Related
Vba To Set Duplex Printing
I am trying to use code from a Microsoft site to set the printer to duplex, but it crashes right away. "Printer" is highlighted, and the error says "variable not defined." ...

View Replies!   View Related
Userform - Printing
I have a problem I am using the following code,

Private Sub cmdPrint_Click()
End Sub

How is it possible to get the userform to be printed in landscape

View Replies!   View Related
Automatic Printing To A PDF
how to print automatically from Excel to a PDF file. After a couple of days of searching and tweaking, I've got what I think is a fairly good solution for automating your printing of worksheets to PDF files.

This solution requires the use of PDF995. This is a free utility available at This is a print driver that allows you to print to a PDF file. The file is compatible with Adobe and can be read with the Adobe reader like any other PDF. The free version does pop-up some advertising with each print, but the automation works with around the pop-ups. I believe the full license version is about $10 and doesn't produce the pop-ups.

The challenge in automating a PDF process is that the PDF driver will prompt the user for a filename. This is ok if you are printing just one sheet, but if you need to automate the production of several PDFs, you need to be able to specify the name of the file in the code. The subroutine SheetToPDF presented below allows you to specify a single worksheet and the full filename for the PDF. I've included all the code and external declarations needed. The two subs at the bottom give examples of how to call SheetToPDF with the passed parameters.

'Needed to Read INI file settings
Declare Function GetPrivateProfileString Lib "kernel32" Alias _
"GetPrivateProfileStringA" (ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, ByVal lpDefault As String, _
ByVal lpReturnedString As String, ByVal nSize As Long, _
ByVal lpFileName As String) As Long

'Needed to Write INI file settings
Declare Function WritePrivateProfileString Lib "kernel32" Alias _
"WritePrivateProfileStringA" (ByVal lpApplicationName As String, _
ByVal lpKeyName As Any, ByVal lpString As Any, _...........................

View Replies!   View Related
Duplex Printing
I have a workbook with 4 spreadsheets, each taking 1 page to print.

I want Sheet 2 to print on the reverse side of Sheet 1 and Sheet 4 on the reverse of Sheet 3 so that all four pages of data takes 2 sheets of paper to print.

I have tried selecting 2 sheets at a time and 4 sheets at a time but printing result is always single sided even though "duplex" is selected in printer properties. In the Print dialog box I have tried selecting "Active Sheets", "Entire Workbook" and even "Selection". I've also tried specifying pages 1-4 rather than All. Eventually, by printing to a PDF creator, I have concluded that Excel is treating each tab is a separate print job. i.e. I get 4 separate PDFs.

View Replies!   View Related
Misaligned Printing
I am automating a paper form that collects information from 7 other paper forms and then prints out the results. I have created an excel spreadsheet to do this but I am having problems getting the printed output to match the print preview.

I have inserted an image of the form into the sheet header and aligned the cells on the sheet so that the information is in the correct position when previewed in "print preview".

The problem is that, although this will print correctly on the machine I created it on, it is misaligned on any other machine I have tried.

View Replies!   View Related
Printing A Sheet For Every Day
I have this attached sheet that i need to print one for every day for the next 12 months.

The problem is i can find a way of doing this and getting the cells in red in row 6 to change to the next date.

View Replies!   View Related
Suppress Printing With VBA
What i have is over 20 worksheets which have information on them that i want to print when selected so, i have a "main page" with a variety of options for the user to select (by check box) and when they are happy with their selection you would click another check box to print out, i have done this because the printer is set well away from the users and if they printed of sheet by sheet then lots of miles treading back and forth to the printer room would happen so, i thought by doing it this way it would batch print all selected sheets after selection, the code is set up to print all sheets which are selected by "true" in cell O2.

This is no problem as it works well but the code also prints when the check box is de selected. What I would like is a message box to appear before the main macro runs for the user to select "yes or no" to confirm printing. I have put code in this for the command but it will not run the main magro if you select "yes"...below is the code for the main print loop...I think the code for print message should appear before this...

View Replies!   View Related
Label Printing
I need to print quite a few mailing labels for Christmas cards from an Excel 2000 Worksheet. Could someone list the steps I must take to do this?

View Replies!   View Related
Lists And Printing
I've made a 40 page list on Excel, On the very top of this list is my titles of whats is in the collums. How do I repeat this through out, so it appears on the top of every page.

View Replies!   View Related
Highlighting And Printing ...
I have attached a sample sheet which is for invigilation of exams. In columns D, E & F are the initials of people invigilating at different times. What I want to able to do is to print personised sheets for each person where there initals are in bold and the box has a black border around it. This is very labour intensive if I do it manually as have to highlight one person, print, unhighlight and rehighlight the next person and so on. What I was wondering is could I use a macro to automate this process. So it has a list of all the initals and it searches through and highlights the person and prints it and then moves onto the next.

View Replies!   View Related
Process Before Printing
I need to print a worksheet. The sheet has rows of a specific height (45) and data in one cell grows - adding comments/notes with date attached so that last one entered is displayed, the rest get shoved down.

I need to sometimes print out the sheet. However, I want to have all the notes shown so would like to (1) autofit all rows, (2) print the sheet and then (3) put all rows back to row height of 45. All this I would LIKE to have done by "trapping" the print button on the normal Print area

I have attached some code, but the sheet (1) does not print at all, (2) the code is sometimes executed twice (in debug mode followed it) and (3) sometimes does not set the row height properly either at autofit or static height.

View Replies!   View Related
Printing From Variable Row
I used the macro recorder to take selected cells from a worksheet and automaically print the selected area. It works great - but i (as usual) want it do more - more specifically, i want it to print, say 10 rows, from any row i select.

The worksheet is a live schedule which is updated constantly as production works through the scheduled orders. I want to identify the row which has the current running production order and print that row and the next ten.

how to use the input box to ask for the row # but don't know how to code the actual passing of that variable. I figure i can then marry my existing code to make a working frankensteinish macro.

View Replies!   View Related
PRINTOUT Not Printing
I have a workbook on a web site. That workbook has the following

sFileName = sPath & ThisWorkbook.Worksheets("Retailer Lists"). Range("A" & c).Value & "/Fact+ Sheet.xls"
Workbooks.Open Filename:=sFileName

When I run the code, the active workbook is the "sFileName" file. There are a couple of problems that I can't seem to get around. First of all, when I run the code, I get a Method 'Open' of object 'Workbooks' failed error. If I debug, it is on the Workbooks.Open statement shown above. If I do nothing but hit F8, the file opens. The second issue is nothing prints. The file is available to me and I can access things on the sheet, but it will not print. By the way, the CLOSE command works perfectly. Is there a different way that I should be accomplishing the printing?

View Replies!   View Related
Fit One Page When Printing
I need to create a macro code to adjust the width of the columns so it fit in one page for printing. So If it only has 3 columns, the widht will be wider but if it has 200 columns then the width will be much smaller.

View Replies!   View Related
Use Different Color For Printing
I am coloring every other row of a worksheet to have a 'green bar paper' effect. The color desired for the screen does not produce a dark enough gray shade on print jobs. I have found some useful color wheel tools on the web to darken the color without changing color shade but we are changing the customers default color scheme to get this darker print shade.

Is there a way in VBA code to set a regular screen color property and a separate print color property for a range? How does Excel decide what level of gray shading to use for colors anyway? For two close but different brightness colors it appeared to generate the same gray shade (but my eyes aren't the greatest).

View Replies!   View Related
Printing To Labels For Years
I created a wedding list with a bunch of fields for each household: first name person 1, second name person 1, first name person 2, second name person 2, street #, street address, apartment, city, state and zip. Then I realized that I probably needed to combine fields for each line of the address so I created 3 combined fields: 'combined 1 ' that looks like this "joe smith & patsy cline," a 'combined 2,' that looks like "14 jones street, #3," and a 'combined 3,' that looks like "New York, NY 10037."

I haven't printed to labels for years and when I did some quick research via the help function on excel it said to print labels via word...which worked fine until i got to this section: " In the Mail Merge Recipients dialog box, click any column labels in your data that correspond to the Word identifiers on the left. This step makes inserting your data in the form documents easier. For more information about matching fields, see Word Help. "

I have no idea what this means, but here's what I need to figure out: " how do I print labels using just 3 of 8 existing columns in my spreadsheet, i.e I just want to use combined 1, combined 2 and combined 3 for the 3 lines of the address. My first instinct was just to cut the contents of the combined fields into a new spreadsheet and just do it taht way, but I created the combined fields using a formula which relates to the other fields........

View Replies!   View Related
Printing TAB List As An Index
how to print a list of the (named) TABS of several sheets in one file as an index page?

View Replies!   View Related
Printing Select Tabs Only
I have a Services Quote work book that contains many tabs only some of which may be used for a particular quote.

I would like to have a macro that I could assign to a button that would check the value of a particular field on each tab and if that field is greater than 0, then it should select that tab as one to be printed. Once all tabs are checked and either selected or not selected, the macro should print the selected tabs.

View Replies!   View Related
Printing Fileinformation On The Sheet
I have a file that needs to be dated when it is printed. Is there any way to make the following things to appear on the sheet/workbook:

- Printing date/time
- filename of the current file that is printed
- the date of latest time/date the file was edited
- the person who printed the file (based on the user profile that is logged in the system.

View Replies!   View Related
Removing Rows For Printing
I have a report that pulls data from another worksheet in Range A26:J58.
What I want to be able to do is assign a button for printing the report but
before printing from A1:J70 removing or hiding any row in the A26:J58 range
where there is no data. The range is filled from row 26 down so it is not a
random fill.

Also, I want to save this workbook as a template so that it can be used over
again, so I guess it would not be good to delete the rows in the range
otherwise I would have to recreate them.

View Replies!   View Related
VBA Conditional Page No Printing
I need a code that will print a page only if there is a value in cell G4 for example.
Im think I have part of the code but cant work out the " if " part
ActiveWindow.SelectedSheets.PrintOut From:=1, To:=1, Copies:=1, Collate _

View Replies!   View Related
Disable Printing Of A Worksheet
I have a workbook of some 15 worksheets - however there is just one of the worksheets I want to disable the printing of it. So that when users select print whole document - all worksheets will print except for thus one worksheet

The worksheet tab is named "15.ADMIN WORKBOOK CONTROL ONLY"

I know I need to put some vba code into the code area of that worksheet

I tried this code but it didnt work

Private Sub Worksheet_BeforePrint(Cancel As Boolean)
Cancel = True
End Sub

View Replies!   View Related
Printing All Files Within A Folder
Ive just finished creating a continuos rolling spreadsheet that will allow people to keep adding records onto. I then have a macro that will every so often take each record and sort them by month and week ending date. So Im left with a month folder with 4 week ending date folders within it etc. Now for reporting purposes those files will need to be printed, so what I am after is a mthod of selecting one of the month folders, and it will automatically go into each weekending folder and print all the files within.

View Replies!   View Related
Macro For Printing :: By Hit Of Button
i am after a macro that will print multiple sheets in hit of a button, the ranges are from A1 to the last row of the data. Now there are sometimes cells which have no data, so was not sure if this will be a problem. At momenet it take me at least couple of minutes to print everything out.

View Replies!   View Related
Printing Userform Listbox
I have a userform with frame and a listbox in a frame. Listbox is higher than a frame so a frame has a scroll bar.

How can I print the whole listbox with all items?

The code UserForm.PrintForm will print just the 'visible' part of listbox, but not the rest of it which is hidden in the frame

View Replies!   View Related
Printing Some Rows In Every Page
I am making a project in which there is vast data of around 10-15 pages to get print...but due to vast data its not possible to get all printed in 1 pages...So i want that cell A1:K4 & A47:K53 to get print in every sheet...Header and footer is not posisble due to some logo at the end of the there anyway for such printing option...

View Replies!   View Related
Copyright 2005-08, All rights reserved