Solved

printing hidden columns of excel file

Posted on 2004-08-16
5
607 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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

809 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