Solved

printing hidden columns of excel file

Posted on 2004-08-16
5
608 Views
Last Modified: 2012-06-21
i have this code:
Sub excelprocess()
    On Error GoTo xlserrorhandler
    Set excel_app = New Excel.Application
    Set excel_wb = excel_app.Workbooks.Open(fileloc, 0)
    DoEvents
    For i = 1 To excel_wb.Worksheets.Count
        Set excel_ws = excel_wb.Worksheets(i)
        excel_ws.PrintOut
    Next i
    PrintDetector
    Set excel_ws = Nothing
    excel_wb.Close
    Set excel_wb = Nothing
    excel_app.Quit
    Set excel_app = Nothing
    Exit Sub
xlserrorhandler:
    errorflag = 1
    excel_app.ActiveWorkbook.Close False
    excel_app.Quit
    Set excel_app = Nothing
End Sub

how can i print hidden columns of an excel file i open without messing my code?
0
Comment
Question by:4ceReconSniper
5 Comments
 
LVL 3

Expert Comment

by:realrael
ID: 11808013

just before you print out, add code to unhide hidden columns. - rael

Worksheets("Sheet1").Columns("A").Hidden = False
0
 
LVL 3

Author Comment

by:4ceReconSniper
ID: 11808310
whats A?
0
 
LVL 3

Expert Comment

by:kay2g
ID: 11810185
"A" would be the whole column A that it would be revealing so that you can print it out. I would just extend this to stretch a large range so that it would reveal any possible column that would be there, like this:

For i = 1 To excel_wb.Worksheets.Count
        Set excel_ws = excel_wb.Worksheets(i)
        excel_ws.Range("A:ZZ").Hidden = False
        excel_ws.PrintOut
Next i

Hope this helps
Kay
0
 
LVL 3

Author Comment

by:4ceReconSniper
ID: 11817042
i think IV is the last column in an excel worksheet?
0
 
LVL 2

Accepted Solution

by:
mogadishuhero earned 250 total points
ID: 11818184
as far as i know it reaches a maximum of IV and i have modified the your code, instead of using Ranges i use columns and rows here so that it would read what are active not assuming the maximum range this the code:
Sub excelprocess()
    Dim i As Integer
    'On Error GoTo xlserrorhandler
    Set excel_app = New Excel.Application
    Set excel_wb = excel_app.Workbooks.Open(fileloc, 0)
    'excel_app.Workbooks.Open(fileloc, 0)
    DoEvents
    For i = 1 To excel_wb.Worksheets.Count
        Set excel_ws = excel_wb.Worksheets(i)
        excel_ws.Visible = True
        excel_ws.Columns.Hidden = False
        excel_ws.Rows.Hidden = False
        excel_ws.PrintOut
        DoEvents
    Next i
    PrintDetector
    Set excel_ws = Nothing
    excel_wb.Close False
    Set excel_wb = Nothing
    excel_app.Quit
    Set excel_app = Nothing
    Exit Sub
xlserrorhandler:
    errorflag = 1
    excel_app.ActiveWorkbook.Close False
    excel_app.Quit
    Set excel_app = Nothing
End Sub
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

837 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