Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

printing hidden columns of excel file

Posted on 2004-08-16
5
Medium Priority
?
614 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 1000 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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
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…
Suggested Courses

705 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