Solved

printing hidden columns of excel file

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

920 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

15 Experts available now in Live!

Get 1:1 Help Now