Click here to Skip to main content
16,006,378 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: int to a Pin
pnpfriend24-Jan-03 9:41
pnpfriend24-Jan-03 9:41 
Generalgenerating report based on values in 2textboxes Pin
mcm24-Jan-03 4:19
mcm24-Jan-03 4:19 
Generaladd new IE button in registry - vbs Pin
Florin Ochiana23-Jan-03 21:04
Florin Ochiana23-Jan-03 21:04 
GeneralRe: add new IE button in registry - vbs Pin
Florin Ochiana23-Jan-03 23:08
Florin Ochiana23-Jan-03 23:08 
Generalget single cell name.. Pin
pnpfriend23-Jan-03 10:39
pnpfriend23-Jan-03 10:39 
GeneralRe: get single cell name.. Pin
Nick Seng23-Jan-03 14:43
Nick Seng23-Jan-03 14:43 
GeneralRe: get single cell name.. Pin
pnpfriend24-Jan-03 4:28
pnpfriend24-Jan-03 4:28 
Generalexcel.sheet.setprintArea Pin
pnpfriend23-Jan-03 4:49
pnpfriend23-Jan-03 4:49 
Hello Gurus...

I want the exiting excel file to open it, format it and print it.

opening and formating part I have ( mostly) done ... but to printing giving me problems.. when the file get print, there are lots of empty pages because of the last cell.

let's say, the sheet contain only two cells that has some data. the first cell is A1 and the last cell is z130 and there are no data in the cells between first and last cells.

So when I call PrintOut method it prints all the empty pages.

I'm trying to set the print area for the excel sheet because I don't want to print empty pages. But how can i set the print area only to print that two cells???

I tried look every cells whether if it is empty or not, if empty don't do anything but if not empty, set the range and set the printarea... the following is my code..I know it is wrong but don't know how to fix it
<br />
<br />
Function SetPrintArea(sheet As Worksheet) As Worksheet<br />
    Dim r As Range<br />
    Set r = sheet.UsedRange<br />
    <br />
    Dim newRange As Range<br />
    Dim i As Integer<br />
    Dim j As Integer<br />
    <br />
    For i = 1 To r.Rows.Count<br />
        For j = 1 To r.Columns.Count<br />
            If Not Cells(i, j).Value = "" Then<br />
                newRange = newRange(Cells(1, i), Cells(i, j))<br />
            End If<br />
        Next j<br />
    Next i<br />
    newRange.Cells.Select<br />
    sheet.PageSetup.PrintArea = Selection.Address<br />
    Set SetPrintArea = sheet<br />
End Function<br />

Thanks
GeneralRe: excel.sheet.setprintArea Pin
Nick Seng23-Jan-03 14:35
Nick Seng23-Jan-03 14:35 
GeneralRe: excel.sheet.setprintArea Pin
pnpfriend24-Jan-03 3:30
pnpfriend24-Jan-03 3:30 
GeneralRe: excel.sheet.setprintArea Pin
Nick Seng24-Jan-03 7:51
Nick Seng24-Jan-03 7:51 
GeneralRe: excel.sheet.setprintArea Pin
pnpfriend24-Jan-03 9:39
pnpfriend24-Jan-03 9:39 
GeneralRe: excel.sheet.setprintArea Pin
Nick Seng26-Jan-03 14:31
Nick Seng26-Jan-03 14:31 
GeneralExposing UserControl events to IE Pin
glaidler22-Jan-03 6:03
glaidler22-Jan-03 6:03 
Generalpopulating datagrid based on same field in database Pin
mcm22-Jan-03 2:01
mcm22-Jan-03 2:01 
GeneralAdding Properties at runtime in PropertyGrid Control Pin
RohanD22-Jan-03 0:53
RohanD22-Jan-03 0:53 
GeneralVB.NET : How Can i Bind data to CheckBox Pin
intibnin21-Jan-03 2:01
intibnin21-Jan-03 2:01 
Generaltype mismatch Pin
mcm20-Jan-03 10:17
mcm20-Jan-03 10:17 
GeneralRe: type mismatch Pin
SimonS22-Jan-03 3:01
SimonS22-Jan-03 3:01 
Generallooping through first row of datagrid without moving onto next Pin
mcm20-Jan-03 9:55
mcm20-Jan-03 9:55 
GeneralRe: looping through first row of datagrid without moving onto next Pin
Richard Deeming21-Jan-03 1:45
mveRichard Deeming21-Jan-03 1:45 
Generalquery on scrrun.dll Pin
shanksprasad19-Jan-03 18:42
shanksprasad19-Jan-03 18:42 
GeneralImort an Event from a VC++ DLL Pin
Benno Huebscher19-Jan-03 3:04
sussBenno Huebscher19-Jan-03 3:04 
GeneralUsing SourceSafe Pin
Ilan Ehrenfeld19-Jan-03 1:42
Ilan Ehrenfeld19-Jan-03 1:42 
GeneralRe: Using SourceSafe Pin
Steven Lyons20-Jan-03 13:02
Steven Lyons20-Jan-03 13:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.