Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




How To Set Print Range


Hello all







I have made print preview. But it was large that A4 size. I am notgetting that how to set print range and if it overflow then it goes tonext page.



And how to give next page for print preview and printer





Thanks



Amrit




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Print Range Of Pages, Find Length Of Document To Print
Hi, I am trying to accomplish two things.
1) I would like to find out how many pages would print out, IF I were to print. ie. Warn the user: "You have asked to print out 500 sheets at $4.50 a sheet."
2) I would like to choose a range of pages to print out, without that range set as the "default" the next time the print function is called. So, my current printing method below is not what I would like. (Unless there is a way to restore defaults?) It displays the normal print dialog, and remembers the last print range entered by the user.

I am displaying web pages on a form within the webbrowser control. Some are very long, so these features are important to me. How it is done is less important. Any advice is appreciated. Thanks!

Here is my very simple example code:

Code:
Option Explicit

'Load a web page
Private Sub Command1_Click()
WebBrowser1.Navigate ("http://www.vbworld.com/")
End Sub


'Brings up the print dialog box on button click.
Private Sub Command3_Click()
Dim eQuery As OLECMDF
eQuery = WebBrowser1.QueryStatusWB(OLECMDID_PRINT)
If Err.Number = 0 Then
If eQuery And OLECMDF_ENABLED Then
WebBrowser1.ExecWB OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER, "", ""
Else
End If
End If
End Sub

Private Sub cmdNavigate_Click()
Dim txtNavigate As String
WebBrowser1.Navigate txtNavigate
End Sub

Print Command In Vb6 To Print A Range In An Excel Worksheetsheet
Thank you for you assistance in populating an excel sheet from a vb6 user form textbox.

I am now struggling to print the excel sheet from vb6 command button.

I can print the worksheet but it is blank as I cannot work out how to set the print range.

Assistance would be appreciated as, after hours of trying, I am about ready to scream!!

Print A Range Of Dates
I'm trying to pull appointment dates from a database and just print them into a picture box. How do I search for the dates? I have two input boxes: one with the start date and one with the end date. Those dates, and the dates between them need to print into the picture box. I have no clue how to go about this. Here's what I have so far:


Private Sub mnuAppointments_Click() 'on a drop down menu

Dim strReportDate1 As String, strReportDate2 As String, foundFlag As Boolean

strReportDate1 = UCase(InputBox("Enter the Start Date (MM/DD/YY):"))
strReportDate2 = UCase(InputBox("Enter the End Date (MM/DD/YY:"))

If Len(strReportDate1) > 0 Then
datContacts.Recordset.MoveFirst
foundFlag = False

Do While (Not foundFlag) And (Not datContacts.Recordset.EOF)
If Trim(UCase(datContacts.Recordset.Fields("Next Appointment").Value)) = strReportDate1 Then
foundFlag = True
Else
datContacts.Recordset.MoveNext
End If
Loop

If Not foundFlag Then
MsgBox "Please try again"
datContacts.Recordset.MoveLast
End If
Else
MsgBox "Please enter a start date"
End If

Print A Worksheet Range From Vb 6.0
G'day All,

I have an application in vb 6.0 that collects data, saves it to a database then collects the data from the database and sends it to an excel worksheet from where it is printed.

My problem is that I need to print a specified range of cells (not the whole worksheet) for one of the reports.

Can anyone help me with the code for a cell range?


Code:

Dim comRpt As Command
Dim strErrorMsg As String
Set comRpt = Nothing
Set comRpt = New Command
Set rstReportDetails = New ADODB.Recordset

Set AppExcel = CreateObject("Excel.Application")
Set wBook = AppExcel.Workbooks.Open("S:Application-Res aApplication-all.xls")
Set wSheet = AppExcel.ActiveWorkbook.Worksheets("Credit")

wSheet.Cells(5, 3).Value = rstReportDetails("ApplicationNumber")
wSheet.Cells(5, 5).Value = rstReportDetails("LoanAmount")
wSheet.Cells(26, 2).Value = rstReportDetails("Description")
wSheet.Cells(27, 2).Value = rstReportDetails("MainPurpose")
wSheet.Cells(29, 1).Value = rstReportDetails("Conditions")
wSheet.Cells(33, 2).Value = rstReportDetails("CurrentlyWith")
wSheet.Cells(11, 4) = frmCreditCheck.txtGeneral.Text

Call wSheet.PrintOut
Any help would be appreciated. Thanks.

Dynamic Print Range
Hello to you

I need a subroutine that will look at a worksheet and identify the last cell that contains data and set the print area, up to and including that last cell. It must be renewable - i.e. it works every time new data is inputted onto the sheet.

Can anyone help me?????

Dynamic Print Range
Hello to you

I need a subroutine that will look at a worksheet and identify the last cell that contains data and set the print area up to and including that last cell. It must be renewable - i.e. it works every time new data is inputted onto the sheet.

Can anyone help me?????

Print Range In Excel
How can i set the print range in excel so that it will always print 1 page, if i use printArea it prints 2 pages instead of 1. Is it possible to always print to 1 page?


VB Code:
ActiveSheet.PageSetup.PrintArea = "$A$1:$R$55"

Clear Everything Outside Of Print Range
I am using the following sub routine in VB to clear all data in cells and columns outside a designated print range.
The problem is it only clears out up to Z. There are a few columns AA - AF that gets left. Why is this?

Cna you help?

-------------
Next shp
        
        If sht.Name <> "Wellhead Data Sheet" Then
        If sht.PageSetup.PrintArea <> "" Then
            lRight = Right(sht.PageSetup.PrintArea, _
              InStr(sht.PageSetup.PrintArea, ":"))
            uLeft = Left(sht.PageSetup.PrintArea, _
              InStr(sht.PageSetup.PrintArea, ":") - 1)
            Set rngClear = sht.Range(lRight).Offset(0, 1)
            rngClear.Select
            Range(Selection, Selection.End(xlToRight)).EntireColumn.Delete
        End If
        End If
        Range(uLeft).Select
        sht.Protect ("ciw")
---------------

Print Block Of Range
I have this sheet with 5 block of range.
How to make a macro and assing to the button in this mode:

Set range from A to P (last cell in this case cont last cell from A) and print a copy
Set range from R to AG (last cell in this case cont last cell from R) and print a copy
ecc...


Peraphs is a init:

Option Explicit
Sub ShowUsedRange()

Dim ELENCO As Worksheet
Dim RIGA_MAX As Integer
Dim COLONNA_MAX As Integer
Dim I As Integer
Set ELENCO = Sheets("STAT_NEW")
RIGA_MAX = ELENCO.Cells(65536, 1).End(xlUp).Row
COLONNA_MAX = 16
With ELENCO
For I = 1 To 5
ActiveSheet.PageSetup.PrintArea = "$A$1:" & Cells(RIGA_MAX, COLONNA_MAX).Address
'HERE THE COMMAND TO PRINT OUT AREA
COLONNA_MAX = COLONNA_MAX + 16
Next I
End With
End Sub

Select Print Range
I have multiple charts on one sheet. When printing i want to select both the charts to be selected..either print on one page or more than one page
Can anyone tell me how to do it through VB ?

-ash

Print Data Between A Date Range
I have a data base with a long list of enteries which I would like to beable to use a macro to print enteries between to dates. If having it print is to hard how do I get to copy the enteries between the dates to a new worksheet

Appending A Range To A Print File
Yikes.

Haven't been here for a while...

Seem to be going down a lot of dead end threads with this one.

Need to print various ranges to either the active printer &/OR append to a file.
To the active printer,
myrange.printout is working great
to append to a file i just seem to get more lost.
- does not seem to be a vba utility?
- shell(whatever) is getting me lost... no file
concatenate function in DOS?

help greatly appreciated.

* * * *.. i keep hitting tab here and, duh, of course going to the "Submit NEw Thread" button. Hope i haven't inadvertently submitted any incompletes or extras

thanks again..
kak5157

Use A Macro To Print An Area, But Range Is Always Different
Hi everyone,

I have a macro that formats some data for me. I use this macro very often and I would like it each time that it is run to create the right print range, so that I can immediately print of my sheet if I need to. The problem I have is that although I always have the same number of columns at the same width but there are always more or less rows than the last time I printed. How do I get VBA to recognise this and select the print area that has data only. Also, there are some rows in my sheet that have no data...is this a problem (they are in between data though).


Cheers

Max

Print Range In Excel From Vb Application
I have several vb user forms which populate an excel spreadsheet. I need to put a command button on a user form which will print out the excel sheet that has been populated. At no time will the user see the excel workbook.

I have managed to get as for as printing the sheet but the print-out is blank as I have been unable to work out how to tell the printer what the print range is.

I realise that this must be a very basic question but I would appreciate some help.

Setting A Range Equal To That Of The Print Area
I have found code that will allow me to attach a certain range, on an excel sheet, into an outlook e-mail and then send it.

However, it requires you to select the range.

The range I want sent, happens to be the same range as the printable area.

Is there a way to just have the rangeToSend = printArea?

VBA Fill Formulas In Worksheets And Print Range
:huh: Hiya

Maybe you can help me with this one

Do you know what code I would need to fill down formulaes in subsequent worksheets depending on figures in a master sheet. Say Range("a3").Value

For example if the master sheet had 1 apple, 2 oranges and 3 tomatoes, how could it recognise the number of each and copy the last row of formulas according to the number?

I would then require the code to copy down the last row of formulas twice in the oranges worksheet and three times in the tomatoes. Basically it needs to be smart enough to formulas according to the number inserted in the first sheet.

Finally I need the macro to print say the last twenty rows of formulas in each worksheet ( a set print area which will encompass the new formulas that have been copied down).

It sounds easy but I think it is much more difficult

Here is the code I am using for the copy fill
Code:
Range("F24:G24").Select
Selection.Copy
Sheets("Macq True Index FI- FIFO").Select
Range("A130").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
ActiveWindow.ScrollWorkbookTabs Position:=xlFirst
Sheets("Data Sheet 106").Select
Range("C24:D24").Select
Application.CutCopyMode = False
Selection.Copy
Sheets("Macq True Index FI- FIFO").Select
Range("A131").Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Range("C129:H129").Select
Application.CutCopyMode = False
Selection.AutoFill Destination:=Range("C129:H131")
Range("C129:H131").Select
Range("H130").Select
Sheets("Macq True Index FI- FIFO").Select
Range("A130:A131").Select
Selection.Copy
Sheets("Macq True Index FI (Gains)").Select
Rows("135:135").Select
Application.CutCopyMode = False
Selection.Copy
Rows("136:137").Select
ActiveSheet.Paste
Application.CutCopyMode = False
Range("B137").Select
Selection.ClearContents
Range("N136").Select
ActiveCell.FormulaR1C1 = _
"=IF(RC[-12]=0,0,IF(RC[-7]-RC[-6]-RC[-5]=0,((RC[-12]-R[-1]C[-12])*RC[-4])," & _
"((RC[-7]*(RC[-12]-RC[-11]))+(RC[-6]*(RC[-11]-RC[-12]))+(RC[-5]*(RC[-10]-R[-1]C[-12])))))"
Range("N137").Select
ActiveWindow.LargeScroll ToRight:=-1
Range("B137").Select
ActiveCell.FormulaR1C1 = "1.001"
Range("B138").Select
End Sub

Common Dialog/PrintDialog API Print Range
All,
I have exhaustively searched this website as well as other to find how to activate the Current Page or the Pages radio options on either the commondialog control or the PrintDialog API. If anyone could point me in the right direction that would be helpful.

I have been setting the .Flags to cdlPDPageNums, in fact, I have tried all available flags in some combination. Maybe there is a trick to an And/or clause in the setting of the flag that I am just not getting correct.

Thanks in advance

VBA Excel: Combine Print Range On Same Page
Assign multiple print ranges within a single Excel Worksheet

Is this performed through a pagesetup function? Please get me started...thanks

Private Sub CommandButton1_Click()

Dim rCol As Range
Dim rCell1 As Range, rCell2 As Range
Dim Sht As Worksheet

'Set range variable to Selection
Set Sht = ActiveSheet
Set rCol = Sht.UsedRange.Columns(1)
'Insert page breaks
Sht.PageSetup.PrintArea =

Loop Through Named Range And Lock Range Name Based On Values
ok..basicallly I created a worksheet called 'calendar'
this calendar worksheet has 12 named ranges

rngJanuary,rngFebrary....to rngDecember(yes its a calendar)

all of these named ranges are also inside one big range called rngcalendar.

Basically I want to accomplish the following.

when the workbook get opened get the last day of the last month the user entered a value and lock every other named range after the month of the named range the last value was stored in.

eg..if on march 20th the user entered a "w" as a value I want to lock
RngApril through rngDec.

in other words force them to finish entering all values for a month before continuing to the next.

if IT helps all my days of the month are in ltgrey coloring
and the vales the enter go below the day value
in normal white cells(see attachment)


I already validate the entried in the
Private Sub Worksheet_Change(ByVal Target As Range) event but dont know how to accomplish the above step.

Excel Range In Variant Array, 'Subscript Out Of Range' Error
Morning Guru's

I have been having problems with this function for a few days now. I'd be most grateful if one of you could set me straight with this. Here is my code:


Code:

Private Function RemoveNulls(ByVal srcRange As Excel.Range, ByVal lastRow As Long)
MsgBox srcRange.Address

Dim i As Long
Dim xlVals() As Variant
xlVals = srcRange.Value
For i = LBound(xlVals) To UBound(xlVals)
If xlVals(i) = -9999 Then xlVals(i) = 0
Next i
srcRange.Value = xlVals
Set srcRange = Nothing
End Function


The compiller gives me the 'Subscript out of Range' error on the line:
If xlVals(i)=-9999 Then xlVals(i)=0

In-fact if I try to get a msgbox or something to display any value in the array, I get the same error. The Lbound and UBound functions are returning the expected values, therefore I believe that the array definately contains data!?

Any Ideas Amigo's?

Thanks

Copying Dynamic Range Based On Cell Outside Of Range
i am copying a dynamic range of cells from twelve different worksheets. i need to select a range that starts of g10 on every sheet, but ends differently on every sheet. the range ends depending on column A in the last row of each range, the word 'total'. i would like to select the range in column g10 down to the cell corresponding with 'total' in column a in column g. For example, if there is 'total' is in a56, i want to select and copy g10-g56. If on another sheet 'total' is in a68, i want to select and copy g10-g68. there is information below the range. i want to ignore the data below altogther. here is the code that i have now for the first sheet. it grabs G10 through the last cell in column g. any help would be appreciated. thanks


Code:
Sheets("January 2005").Select
Range(Range("G10"), Cells(Rows.Count, Columns("G").Column).End(xlUp)) _
Copy Worksheets("SALES REPORT").Range("a2")

Determining Wether Current Cell/range Within A Specified Range
Hi,
I am trying to write a macro for excel spreadsheet.
I am trying to find some function or method to determine wether a particular cell is currently within the specified range or not.

A simple example to illustrate question:

Dim Action_Range as Range
Set Action_Range = Range("A1:H:10")

Dim Current_Range as Range
Set Current_Range = ActiveCell

If Current_Range is part of the Action Range then
'do something
Else
'ignore
End if

Can somebody give some suggestions?
Thanks

Excel Macro, Subscript Out Of Range, But Its In Range?
i have a 2d array:
wds(1 to 24, 0 to 1)
the values in the array are set up correctly, but when i try to
output the values of the array to a cell i get the subscript out of
range error.

Below is the code that ive used to write to the cells, to test
that the array has the correct values the commented out
msgbox was used. (it returned the correct values)
except when i use the same code to assign the value to a cell's value i getthe error.

Code:


dim count1 as integer
count1 = 4
For counter2 = 1 To 24
'MsgBox (wds(counter2, 0))
Sheets("Doubles Results").Range("C" & count1) = wds(counter2, 0)
Sheets("Doubles Results").Range("E" & count1) = wds(counter2, 1)
count1 = count1 + 1
Next counter2



thanks for any replies

ps.
with other languages ive used to do simple calculations like
variable += 3 to add 3 to the variable
variable ++ to increment the variable
is there something similar to this in VB?

Excel: Named Range Will Not Accept New Range Value
I have 2 worksheets in the same workbook
On worksheet "PIR-DT MTH" there is a cell (i.e. "E3") which contains a string value representing a range of cells, eg. "C4:L32"
This range value changes due to specific triggers which aren't important
In "PIR-DT MTH", there is a named range called "PIR1DB" with the same cell range that is stored in the cell "E3"
On the other worksheet "PIR-DT CAT", there is a pivot table "PIR1DTCAT" which has it's data range defined as the named range "PIR1DB" on the previous worksheet
So, the jist of the idea is that when the content in cell "E3" on "PIR-DT MTH" changes, I update the range that the workbook Name "PIR1DB" refers to
When the named range is updated, the pivot table "PIR1DTCAT" will be refreshed to show data for the changed range
I've toiled over this code over and over and over and all the variables show the correct values (using the VB Debug window)
But for some strange reason, the line which is supposed to set a new range to the Name doesn't work at all

The call to the function looks like this:
Call Update_PivotTables("IRReports.xls", "PIR-DT MTH", "PIR-DT CAT", "DTCAT", "1", "E3")

The actual function looks like this (I have placed the actual values in comments at the end of the line so you can follow what is happening):

Public Sub Update_PivotTables(WkBook As String, SourceWkSheetName As String, _
                                ObjWkSheetName As String, InfoType As String, _
                                IRNumber As String, RangeInfoCell As String)

Dim myexcel As Object
Dim myworkbook As Object
Dim sourceworksheet As Object
Dim objworksheet As Object
Dim PivotTableName As String
Dim PivotSourceData As String
Dim NameRef As String
    
    Set myexcel = GetObject(, "Excel.Application") 'Point to active excel application
    Set myworkbook = Excel.Application.Workbooks("IRReports.xls") 'Point to the relevant workbook
    Set sourceworksheet = myworkbook.Worksheets(SourceWkSheetName) 'Point to the relevant worksheet
    Set objworksheet = myworkbook.Worksheets(ObjWkSheetName) 'Point to the relevant worksheet

    PivotTableName = "PIR" & IRNumber & InfoType    ' PIR1DTCAT
    
    If sourceworksheet.Range(RangeInfoCell).Value = "None" Then    ' C4:L33
        'There is no downtime data, hence the pivot table will not be updated
    Else
        PivotSourceData = "='" & sourceworksheet.Name & "'!" & sourceworksheet.Range(RangeInfoCell).Value    ' 'PIR-DT MTH'!C4:L33
        NameRef = "PIR" & IRNumber & "DB"    ' PIR1DB
        myworkbook.Names.Add NameRef, PivotSourceData    'This is the line which doesn't work
        objworksheet.PivotTables(PivotTableName).PivotCache.Refresh
        
        myworkbook.ShowPivotTableFieldList = False
        Application.CommandBars("PivotTable").Visible = False
    End If

End Sub

Changing the Named range doesn't work
The source variable (i.e PivotSourceData) would have the correct information in but and after the line is executed and you check the source range for PIR1DB is says something completely different like "='PIR-DT MTH'!BJ9:BS38"
I have no clue where it gets this from
And everytime you run the code, the strange range changes
Even when I hardcode the value (see below) , it still doesn't work
myworkbook.Names.Add "PIR1DB", "='PIR-DT MTH'!C4:L33"

This is just weird, the fact that hardcoding the values doesn't work means something is drastically wrong somwhere
Am I using any predefined VB words?
Is the sky falling?



Searching A Range And Copying Values Into Another Range
Hi all.

Can someone help me with a problem I have. Working in Excel, I have a range (B11:E15) that looks like:

Date    Consumption    Limit    Excess
01/01/04    1100        1000    100
02/01/04    980        1000    0
03/01/04    760        1000    0
04/01/04    1200        1000    200

What I need is code that will search through the column called 'Excess', and for any values that are greater than 0, copy the entire row (values only, not formatting, or equations that may be behind the scenes) into a new range starting at G12. The code will search each row of the data and for any other rows that have an 'excess', VB will paste it immediately beneath any existing entires in the new range. What I want to be left with is:

Date    Consumption    Limit    Excess
01/01/04    1100        1000    100
04/01/04    1200        1000    200

I hope that anyone can help with this as im brand new to VB. I've been searching many forums for people asking similar questions, but i'm having a hard time of it.

Many thanks to anyone that can help.

Looping A Range Format Identical Range.
Hi Guys and Gals,

Ive been working on this project and needed a simlpe loop though a set range and check for 5 different values, if the values are present format a cell with the identical value on another sheet.

Code:
Sub LeaveTravelOfficeSick()
    Sheets("Leave-Travel-Office-Sick").Select
    Dim i As Integer
    Dim rng As Range, rng2 As Range, rng3 As Range
    Dim rngAll As Range, rngall2 As Range, rngall3 As Range
    'lngNumRows = Columns("Y:BA").CurrentRegion.Rows.Count - 1
    'Set rngAll = Range("N3:R" & lngNumRows)
    Set rngAll = Range("E6:E10000")
    'Set rngall2 = Range("F6:F10000")
    'Set rngall3 = Range("G6:G10000")
    j = 6
    
    For Each rng In rngAll
        With rng
            'If Not IsError(.Value) Then
            Select Case .Value
                    Case "1/2 Leave"
                       With Worksheets("crew").Cells(j, 17)
                        .Value = "1/2 LEAVE" ' displays name OFFICE as cell value
                        .Interior.ColorIndex = 1 ' colours cell black
                        .Font.ColorIndex = 27 'colours text yellow
                       End With
                    Case "Leave"
                       With Worksheets("crew").Cells(j, 17)
                        .Value = "LEAVE" ' displays name LEAVE as cell value
                        .Interior.ColorIndex = 1 ' colours cell black
                        .Font.ColorIndex = 27 'colours text yellow
                       End With
                    Case "Sick"
                       With Worksheets("crew").Cells(j, 17)
                        .Value = "SICK" ' displays name SICK as cell value
                        .Interior.ColorIndex = 1 ' colours cell black
                        .Font.ColorIndex = 27 'colours text yellow
                       End With
                    Case "Office"
                       With Worksheets("crew").Cells(j, 17)
                        .Value = "OFFICE" ' displays name OFFICE as cell value
                        .Interior.ColorIndex = 1 ' colours cell black
                        .Font.ColorIndex = 27 'colours text yellow
                       End With
                    Case "Travel"
                       With Worksheets("crew").Cells(j, 17)
                        .Value = "TRAVEL" ' displays name TRAVEL as cell value
                        .Interior.ColorIndex = 1 ' colours cell black
                        .Font.ColorIndex = 27 'colours text yellow
                       End With
            End Select
        End With
    j = j + 1
    Next rng
End Sub


I built this sub above, it loops through every cell on sheet 1 column E starting at cell E6 and stopping E10000.

It then formats the corresponding cell on sheet 2.

Sheet 1

date jim andy simon
01/01/2007 sick travel sick
02/01/2007 sick sick sick


Sheet 2

date jim andy simon
01/01/2007
02/01/2007


So when the loop finds sick in 01/01/2007 for jim, it then formats the same cell on sheet 2 with sick.

The above sub only does 1 name, to do muliple names i do the same For Each rng In rngAll but just increase the number by 1 and the range value to the next column.

Is there a way to do it with code to save me recreating the loop for 40 more employees?

Any help would be great, will save alot of copy/paste and find/repace values

Al




Edited by - Big Al Inc on 6/19/2007 7:11:07 AM

RESOLVED: Finding A 'range' From Within A 'range'? - Excel VBA
Relative newbie...

Wanting to get coding that will perform a search through a spreasheet range to find a unique row of data (i.e. a match to the contents of first 3 columns), returning the row No. where the match is found. I had thought that a 'range.find' would accomplish this, but have since been advised otherwise.

Anyone any ideas????

Adjacent columns in the row are for additional pertinent data. The search will be used either to retreive the additional data, or, to add to or change it.


thnx in advance,
remalay



Edited by - Remalay on 8/22/2006 6:50:32 AM

Excel Named Range --&gt; Vb Range
Hello,

I have an excel spreadsheet which has a named ranged which defines a table.

in vb.net i want to open the workbook goto the sheet (this i can do) then copy the table using the named excel range stored in the worksheet and then paste this table into powerpoint.

I do not know how to refrence the named range in excel. is it part of the worksheet property? i have not been able to figure that out.

i also might have problem with the pasting into powerpoint. when i paste the data will the grid from excel show up or can i paste it in as a picture?

Thanks

Copy A Range Beneath Another Range
I have two columns with values. I want to copy a range beneath another range how can i do that. I shall explain it with an example. It must be in a macro...

Column A-----Column B-----
10------------- 50
20------------- 60
30------------- 70
40------------- 80

what i want is :

Column A---
10
20
30
40
50
60
70
80


The problem is when i use

....
Selection.End(xlDown).Select
.paste
....

then i past the range in value 40 in column A. I must copy BENEATH column A, how can i realise this

Something like
Selection.End(xlDown+1).Select ??

Thanks in advance

Range Selection: Unknown Range
I'm trying to find a way to select a range based on other values. Range() uses exact cell names (A1 etc). But since the # of rows can vary, exact cell names won't always be valid for any amount of data.

for example,
A7 will always be used, but the last part of the range can vary depending on the # of rows present.

i'm using a user defined function LastRowInColumn() to return the # of the last row present, and i'm using another function to return the correct column #
example
x=LastRowInColumn(2)
y=column#

The problem i'm having is using those 'x' and 'y' variables

What i would need it do to is something like this:

Range("A7:yx").select <--- where y and x are the variables above. Of course this doesnt work because Range() expects exact cell names. I've tried messing with the Intersect function but still the same problems. Any ideas?? Thanks

Copy Range Into Another Workbook Range
I met the following issue.
I have range A and B in the current worksheet of workbook A.
Everyday I need to update workbook B which has same range name in its worksheet. The problem I got is to append range values of the workbook A after the last cell of the range of the workbook B.
Can anybody help me this stuff to solve?

Thanks.

Copy A Range Beneath Another Range
I have two columns with values. I want to copy a range beneath another range how can i do that. I shall explain it with an example. It must be in a macro...

Column A-----Column B-----
10------------- 50
20------------- 60
30------------- 70
40------------- 80

what i want is :

Column A---
10
20
30
40
50
60
70
80


The problem is when i use

....
Selection.End(xlDown).Select
.paste
....

then i past the range in value 40 in column A. I must copy BENEATH column A, how can i realise this

Something like
Selection.End(xlDown+1).Select ??

Thanks in advance

Deleting A Range && Pasting Range
Hi,

I am using Excel and have been trying to delete a couple of ranges using VB. The ranges are Dynamic and so change from order to order. I want to have a button that deletes the values in these ranges.

Private Sub CommandButton1_Click()
ThisWorksheet.Range [ItemN].Delete
ThisWorksheet.Range [Quantity].Delete

End Sub

I will attach the file to show what I mean.
Problems located on "Order Entry Sheet"

B.T.W
I am also having problems with my Process order button. After I have added Items to the order I press Process and get an error.
This does not occur if I don't specify a range to paste the copied range into, but this means that the data could go anywhere on the sheet (last active cell) and not the location I want

Thanks in advance,
Simon

Incrementing From Range(“B1”).Value To Range(“B2”).Value
In excel VB how would I increment programmatically from Range(“B1”).Value to Range(“B2”).Value to Range(“B3”).Value … etc.

This A Range, That A Range Why Vba No Likem?
When I replace "beginning:endings" with actual ranges (say "A40:T40") the program wroks just fine (Or at least it dosn't produce a compile time error). However when I try to run it as written below I get a type mismatch. What gives?

Code:
Sub Copier()
Dim begining As Range
Dim endings As Range
Set beginning = Cells(ActiveCell.Row, 1)
Set endings = Cells(ActiveCell.Row, 20)

For Each Cell In ["beginning:endings"]
If Cell Like "=*" Then
Cell.Copy
ActiveCell = Cells(ActiveCell.Row - 1, ActiveCell.Column)
ActiveSheet.Paste
ActiveCell = Cells(ActiveCell.Row + 1, ActiveCell.Column)
End If
Next

End Sub

Problem With Print, Page Setup, And Print Preview In A Text Editor...
Yes, I have another question.

When I use these exact same functions (with WebBrowser.ExecWB in place of txtScrapbook.Text) in my web browser, it works perfectly. But when I use them in reference to a text box, it doesn't.

Can you tell me where the problem lies, or give me an alternative method? I have a common dialog box already for other functions, so feel free to make use of it if you need to. Thanks.

Code:Private Sub PageSetup_Click()
txtScrapbook.Text OLECMDID_PAGESETUP, OLECMDEXECOPT_DODEFAULT
'opens page setup dialog
End Sub

Private Sub Print_Click()
txtScrapbook.Text OLECMDID_PRINT, OLECMDEXECOPT_PROMPTUSER
'opens common dialog box prompting user to print current web page/parts of current web page
End Sub

Private Sub PrintPreview_Click()
txtScrapbook.Text OLECMDID_PRINTPREVIEW, OLECMDEXECOPT_DODEFAULT
'opens print preview dialog
End Sub

CRYSTAL REPORTS 9 DOES NOT PRINT THE SECOND TIME I CLICK THE PRINT BUTTON ON MY VB6 FORM
the first time i click the print button on my vb6 form the report appears on the screen but on subsequent clicks it does not

the code i have written is follows

private sub commandprint_click
  
     dim CRAPP AS CRAXDRT.APPLICATION
     dim REPORT AS REPORT


     APPPATH = "C:WFBIN"
     REPORTPATH = APPPATH + "" +"INVOICE.RPT"

     SET CRAPP = NEW ARAXDRT.APPLICATION
     SET REPORT = CRAPP.OPENREPORT(REPORTPATH)

     frmmain.crviewer91.reportsource = REPORT
     frmmain.crviewer91.viewreport

    SET CRAPP = NOTHING
    SET REPORT = NOTHING

end sub


is there anyting missing ? Kindly help at the earliest

How To Print Images That Fit To The Page Size Specified In Print Common Dialog?
i need some help in printing the whole image tat fit onto the paper size i specified in Print Common Dialog. I hav a PictureBox array & each PictureBox contains a smaller Picturebox inside. For example : Picture1(index) has a smaller Picture2(index) inside. There are vertical & horizontal scrollbars next to each Picture1(index).

i already hav the basic Print Common Dialog code below. Here's the problem -> I can print out the pictures displayed inside Picture2(index) but the printout will turn out truncated or just part of the whole picture when im printing to a 4R photo size for example and the image displayed in Picture2(index) is larger then the bounding Picture1(index) & i need to use the scrollbars to scroll and view the other portions of the image.

So how to modify the code below to print out the whole image tat fit nicely to the paper size i specified. Thanxs.


'---------------------------------------------------------------------
'CODE
'---------------------------------------------------------------------

CommonDialog1.CancelError = True
On Error Resume Next

CommonDialog1.Action = 5 ' Start the Print Common Dialog

If (Err.Number = cdlCancel) Then Exit Sub
'when Cancel is pressed, exit subroutine

'Code to print the array here

For Pics = Picture2.LBound To Picture2.UBound
If Picture2(Pics).Picture > 0 Then ' If the PictureBox is not empty
Printer.PaintPicture Picture2(Pics).Picture, 0, 0
Printer.EndDoc
End If
Next

'---------------------------------------------------------------------

Automatically Print Data Report Without Clicking Print Icon
is it possible to print records in the data report without loading it clicking on the print icon??? i want the printer to print my data report once i click a message box...but it shouldnt show any datareport...

How To Print Urdu Unicode Characters Using Printer.print Method ...??
Ive written a code for accepting input in text boxes in urd language and store it in access database and similarly i ca retrieve it back from the database and show it in the text boxe from the database in urdu language in vb6.0. But i cannot prin the same urdu unicode characters from the text boxes using th Printer.Print method, and if i do so i got ??????? (questio marks) printed instead of the urdu unicode characters. I eve tried the rich text boxe's selPrint method also but that als print the same ?????.
i wan to print the contents of the text boxes i.e unicod characters in urdu language.
Can anyone tell me how to do this as soon as possible ........??
Can anyone share with me the code for doing the above printing o unicode characters?

Waitin for the reply as earliest .......!!!

Print Error 486: Can&#8217;t Print Image To This Type Of Printer
Hey all
Has anyone seen this error when trying to initiate printform? I am trying to printform in a loop and it gives me this error. The printall subroutine has my printform code. It works perfectly the first time but when it tries to move to the previous record and then print that one I get this error. I searched for information but only found one suggestion where someone suggested putting a time delay in there. I tried that and it still would not print the second time. Help please.......
Thanks so much
Kim

Here is my code:

Code: Private Sub cmdPrintAllForms_Click()
    On Error GoTo SubErr
    Dim i As Integer
    Dim rs As ADODB.Recordset
    
    Set oConn = New ADODB.Connection
    oConn.Open frmSplash.sConn
  
    strSQL = "select * from tblAircraftWO where work_order_no = " & txtWorkOrderNo.Text
    
    Set rs = New ADODB.Recordset
    rs.Open strSQL, oConn, adOpenKeyset, adLockOptimistic
    
    i = rs.RecordCount
    
    rs.AbsolutePosition = txtCardNo.Text
     
    Do While Not rs.BOF
        PrintAll
        
        rs.MovePrevious
        If Not rs.BOF Then
        RetrieveRecords
        End if
    Loop
        
    If rs.BOF Then
        rs.MoveFirst
        MsgBox "You are at the beginning."
    End If
   
SubExit:
    Exit Sub
    
SubErr:
    MsgBox Err.Number & ": " & Err.Description
    Resume SubExit
End Sub

How To Print Urdu Unicode Characters Using Printer.print Method ...??
Ive written a code for accepting input in text boxes in urdu language and store it in access database and similarly i can retrieve it back from the database and show it in the text boxes from the database in urdu language in vb6.0. But i cannot print the same urdu unicode characters from the text boxes using the Printer.Print method, and if i do so i got ??????? (question marks) printed instead of the urdu unicode characters. I even tried the rich text boxe's selPrint method also but that also print the same ?????.
i wan to print the contents of the text boxes i.e unicode characters in urdu language.
Can anyone tell me how to do this as soon as possible ........??
Can anyone share with me the code for doing the above printing of unicode characters?

Waitin for the reply as earliest .......!!!

Print Picture Box (print A Form That Is Too Large For The Screen Or Page)
I got a picture box (Picture1), which contain several picture box'es, labels and
Flex Grid tables, -which I would like to print. Picture1 is quite high (higher than the screen). I found some code that i modified, but the printing only get the labels proper. The Flex Grids and picture box'es only show the border, and not the contents.

Code:Private Const WM_PAINT = &HF
Private Const WM_PRINT = &H317
Private Const PRF_CLIENT = &H4& ' Draw the window's client area.
Private Const PRF_CHILDREN = &H10& ' Draw all visible child windows.
Private Const PRF_OWNED = &H20& ' Draw all owned windows.

Private Declare Function SendMessage Lib "user32" Alias _
   "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
   ByVal wParam As Long, ByVal lParam As Long) As Long


Private Sub Print_Click()
Dim rv As Long
   Me.ScaleMode = vbTwips ' default
   With Picture2
      .Top = Picture1.Top
      .Left = Picture1.Left
      .Width = Picture1.Width
      .Height = Picture1.Height
   End With
   Me.Visible = True
   DoEvents
   Picture1.SetFocus
   Picture2.AutoRedraw = True
   rv = SendMessage(Picture1.hwnd, WM_PAINT, Picture2.hDC, 0)
   rv = SendMessage(Picture1.hwnd, WM_PRINT, Picture2.hDC, _
   PRF_CHILDREN + PRF_CLIENT + PRF_OWNED)
   Picture2.Picture = Picture2.Image
   Picture2.AutoRedraw = False

   Printer.Print ""
   Printer.PaintPicture Picture2.Picture, 0, 0
   Printer.EndDoc
End Sub



Edited by - Zigar on 11/27/2003 3:31:21 AM

Activate The Print Dialox Box When I Print A Data Report
Hello!

I use Visual Basic 6.0.

I have made differents reports with the Data Report component. My problem is when I try to print one of them. I use the next statement:

LlEsmArtReg.PrintReport True

The 'True' is becaruse I want show the Print Dialog Box.

My problem is that the Print Dialog Box not appear at the front, instead of that appears on the back. So the final user have to make a 'Alt+Tab' to see this Dialog Box.

Someone can tell me how to do for this Dialog Box appear at the front, automatically?

Thanks,
Eva Janakieff

I Awna Ask A Bout A Print Code That Can I Print Just What's In The Textbox
print just textbox code please guys
milen regard's

Adding Print Button Or Gettin Vb To Print My Application
Hi does ne1 know how to add a print Button to my application its a canculator i jus want it to print the page

Print Preview - How To Get The Real Print Size In Picture Box???
im previewing the print area in a picture box, but picture box
is little , How can I fit the page I want to print into the visible picture in picture box?
Im using a .bmp file as pic.

JCI

Vbform.print Problem For Msflexgrid Print On OS Win2000/XP
Hello,

I am trying to get my small report print on A4 size paper with vbform.print method (form contains VB components like textboxes/image/labels and MSFlexGrid) and is working properly using VB 6.0 (SP5) on OS win98, but when I try to print same with vbform.print method on OS win2000 OR winXP then it print report properly for all other components on form except the MSFlexGrid component.

All it prints is total black area for MSFlexGrid component. Any one have solution/reason to deal with it?

Thanks...

Print Problems Specifically Enddoc And Print Command
Hello, and welcome to my problem!

My code is below. My problem is this, it wont print, at all, sometimes when I shut the program down it will but not as it is here, or it sends an undefined error back when I hit the command button that holds this.

I just followed a tutorial I found on the net but not specific enough. please help.

Is there supposed to be a print icon with the other objects in the menu that holds the check boxes, list, comboboxes etc that I click and paste onto my form? If so were can I find it, if not who knows.


Private Sub Command1_Click()


Print

Printer.Print
Printer.Print
Printer.Print
Printer.Print
Printer.Print
Printer.Print
Printer.Print Spc(10),
Printer.Print Spc(10), "Selling Price", selltotal.Text, sellall.Text
Printer.Print Spc(10), "Item Cost", costtotal.Text, costall.Text
Printer.Print Spc(10), "Shipping", shiptotal.Text, shipall.Text
Printer.Print Spc(10), "Handling", handtotal.Text, handall.Text
Printer.Print Spc(10), "Other", othertotal.Text, otherall.Text
Printer.Print Spc(10),
Printer.Print Spc(10),
Printer.Print Spc(10),
Printer.Print Spc(10),
Printer.Print Spc(10), "Profit", profittotal.Text, profitall.Text
Printer.Print Spc(10),
Printer.Print Spc(10),
Printer.Print Spc(10),
Printer.NewPage
Printer.EndDoc

thank you ever so much

you should have seen what I could do on my PET

Copyright © 2005-08 www.BigResource.com, All rights reserved