Solved

printing hidden columns of excel file

Posted on 2004-08-16
5
605 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
Comment Utility

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
Comment Utility
whats A?
0
 
LVL 3

Expert Comment

by:kay2g
Comment Utility
"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
Comment Utility
i think IV is the last column in an excel worksheet?
0
 
LVL 2

Accepted Solution

by:
mogadishuhero earned 250 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now