[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 233
  • Last Modified:

print problem

i want to print my document using vb but if i use this code error called "Invalid propety" i'm using o/s windows XP

printer.papersize=256

and my other coding goes

printer.height=234
printer.weight=500
printer.print ="test"
printer.enddoc

if there any chance to customize page ..
writing port
help me

0
prasadharischandra
Asked:
prasadharischandra
  • 18
  • 8
  • 2
  • +2
1 Solution
 
TimCotteeCommented:
Printer.Print "Test"

Rather than

Printer.Print = "Test"

This is a method not a property!

What do you mean in terms of customize page?
0
 
prasadharischandraAuthor Commented:
customize page mean
if i print 3 line then printer should be stop after 3 line but not reject the paper b'cos i want to print it again
sorry
printer.print "test"
small mistake me.i used right way
please help me to do that it's urgent
 
0
 
TimCotteeCommented:
Don't use an .EndDoc as this will cause a form feed to be sent to feed the sheet through the printer.
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
PNJCommented:
"printer.weight=500"

do you mean Printer.Width ?
0
 
prasadharischandraAuthor Commented:
no paper width
and how to stop reject paper
i know only enddoc
0
 
prasadharischandraAuthor Commented:
my paper is continus paper
0
 
prasadharischandraAuthor Commented:
my paper is continus paper
0
 
prasadharischandraAuthor Commented:
my paper is continus paper
0
 
PNJCommented:
You have to match the physical length in the printer with the VB driver length. If you have A4 paper loaded then you need Printer.PaperSize = vbPRPSA4 in your code and so on. VB works through the Windows driver - once you close the printer with .EndDoc you'll get a form-feed as TimCottee says.

I read on this site that you can use Printer.PaperSize = vbPRPSUser, but I've never tried to use it - but see the bottom of the page on this link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vb98/html/vbpropapersize.asp

If you've got continuous paper then do not issue an .Enddoc, you will have to track the paper length for yourself, sending enough line feeds to feed the paper to allow tear-off. Evetually, you'll have to close the program which will send an EndDoc anyway. So, set the printer and the VB to the smallest page length to minimise wastage.
0
 
PNJCommented:
I forgot to say that if you print more lines than VB thinks are on one page then it will send a newpage regardless.
0
 
PNJCommented:
Ah. Printer.PaperSize = 256 IS vbPRPSUser. What Printer.ScaleMode are you using? I wonder if 234 is too small for your printer if (say) you are set to Pixels. Is your error "Invalid Property Value" rather than "Invalid Property"? And which line exactly are you getting the error?
0
 
prasadharischandraAuthor Commented:
my complete code is this error coming on "Printer.PaperSize = vbPRPSUser" called "invalid proprty"
it's only comming on windows XP and Windows 2000
at windowsMe working properly
my printer dotmatrix pannasonic pt3111

and i want to know if i used scalemode vbinches out put only inches example
Height  600 inches
Width   12420 inches



Printer.PaperSize = vbPRPSUser
Printer.ScaleMode = vbInches
'Printer.Height = 5775
'Printer.Width = 12420

Printer.Height = 600
Printer.Width = 12420

'======================

'========================


'==============================================

'Dim IPrinter As String
'
'IPrinter = Printer.DeviceName
'
'
'MsgBox ("Device is " & Printer.DeviceName)



Dim P_Name As String
Dim P_passid As String

Dim P_placeissue As String
Dim P_from As String
Dim P_to As String

Dim P_depflight As String
Dim P_deptime As String
Dim P_depclass As String
Dim P_dapdate As String


Dim P_trnflight As String
Dim P_trntime As String
Dim P_trnclass As String
Dim P_date As String

Dim P_dateissue As String
Dim P_dateexpire As String

Dim P_amount As String
'=================
P_Name = "Saliya"
P_passid = "11111111"

P_placeissue = "Colombo"
P_from = "Colombo"
P_to = "Jafna"

 P_depflight = "777 02082002"
 P_deptime = "03:05"
 P_depclass = "economic"
 P_dapdate = "09 08 2002"


P_trnflight = "776 04082002"
P_trntime = "04:05"
 P_trnclass = "economic"
 P_date = "20 08 2002"

P_dateissue = "09 08 2002"
P_dateexpire = "09 09 2002"
 P_amount = "16,000/="

'


'Printer.Height = 5600
'Printer.Width = 12300

Printer.FontSize = 12
                   
Printer.Print "p___________________________________________________________________________________________________________________________"
Printer.Print "|" & "EXPO AVIATION(PVT)LTD" & Space(30) & ""; Date & PLACE; OF; ISSUE; ""
Printer.Print "|" & "NAME :" & P_Name
Printer.Print "|"
Printer.Print "|" & "FROM :" & P_passid
Printer.Print "|"
Printer.Print "|"
Printer.Print "|" & "TO" & P_depclass
Printer.Print "|" & "TO"
Printer.Print "|" & "FARE"
Printer.Print "|" & "TAXES"
Printer.Print "|" & "TOTAL"
Printer.Print "|" & "BARCODE"
Printer.Print "|"
Printer.Print "|"
Printer.Print "|"
Printer.Print "|"
Printer.Print "|"
Printer.Print "prasad"
Printer.Print
Printer.Print
Printer.Print
Printer.Print "p__________________________________________________________________________________________________________________________"
Printer.EndDoc
                               
0
 
prasadharischandraAuthor Commented:
error on
Printer.PaperSize = vbPRPSUser
please help me
0
 
prasadharischandraAuthor Commented:
error on
Printer.PaperSize = vbPRPSUser
please help me
0
 
prasadharischandraAuthor Commented:
error on
Printer.PaperSize = vbPRPSUser
please help me
0
 
prasadharischandraAuthor Commented:
error on
Printer.PaperSize = vbPRPSUser
please help me
0
 
PNJCommented:
I've just tried a few things. You can't set the paper size to vbPRPSUser. You just set the ScaleMode and then set the SCALEWidth and SCALEHeight. You'll then find that paper size is now set to 256 (vbPRPSUser) and ScaleWidth and ScaleHeight are set to your value.

   Printer.ScaleMode = vbInches
   Printer.ScaleHeight = 11
   Printer.ScaleWidth = 8
   Debug.Print Printer.ScaleHeight, Printer.ScaleWidth

gave me:
 11            8

Looks like ME does things differently. Hope this helps.
0
 
prasadharischandraAuthor Commented:
u maen my coding should be
  Printer.ScaleMode = vbInches
  Printer.ScaleHeight = 11
  Printer.ScaleWidth = 8
  printer.papersize=256
  printer.enddoc

if my paper size width=20.9 centemeters and hight=9.8
then if i used  Printer.ScaleHeight=9.8 then my papersize
is taking hight in centermeter
and my main problem is in windows me my coding working properly but when i run on windows XP and windows 2000
error on papersize=256
why is that
 
0
 
prasadharischandraAuthor Commented:
u maen my coding should be
  Printer.ScaleMode = vbInches
  Printer.ScaleHeight = 11
  Printer.ScaleWidth = 8
  printer.papersize=256
  printer.enddoc

if my paper size width=20.9 centemeters and hight=9.8
then if i used  Printer.ScaleHeight=9.8 then my papersize
is taking hight in centermeter
and my main problem is in windows me my coding working properly but when i run on windows XP and windows 2000
error on papersize=256
why is that
 
0
 
PNJCommented:
1. I've used W2000 and you can't do the "Printer.PaperSize = 256". So, If you want it to be usable on both systems then you need to code in an error trap:

   Printer.ScaleMode = vbInches
   Printer.ScaleHeight = 11
   Printer.ScaleWidth = 8

   On Error Goto PaperErr
   Printer.Papersize=256
   On Error Goto <your original error handler>

   Printer.EndDoc
   Exit Sub
   
<your original error handler>:
   Exit Sub
PaperErr:
   If Err.Number = 380 Then Resume Next
   Resume <your original error handler>
   
2. It'll only mean centimetres if you do:
   Printer.ScaleMode = vbCentimeters


0
 
prasadharischandraAuthor Commented:
u maen my coding should be:

Printer.ScaleMode = vbInches
  Printer.ScaleHeight = 20
  Printer.ScaleWidth = 8

  On Error Goto PaperErr
  Printer.Papersize=256
  On Error Goto herror

  Printer.EndDoc
  Exit Sub
 
herror:
  Exit Sub
PaperErr:
  If Err.Number = 380 Then Resume Next
  Resume herror

if i print it will work???
0
 
PNJCommented:
Yup, give that a go.
0
 
prasadharischandraAuthor Commented:
still not working
0
 
PNJCommented:
Are you working within the IDE? (ie development environment in VB). Have you got "Break On All Errors" set, rather than "Break In Class Module"?

Ensure it's set to "break in class module". I say this because your code should work as you have written it here.
0
 
prasadharischandraAuthor Commented:
it's not workig stiill
0
 
prasadharischandraAuthor Commented:
if i use printer.endoc it will go several rows then stop i want to
go only one row and stop the doc and continuing next page
0
 
prasadharischandraAuthor Commented:
if i use printer.endoc it will go several rows then stop i want to
go only one row and stop the doc and continuing next page
0
 
prasadharischandraAuthor Commented:
if i use printer.endoc it will go several rows then stop i want to
go only one row and stop the doc and continuing next page
0
 
DanRollinsCommented:
Hi prasadharischandra,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept PNJ's comment(s) as an answer.

prasadharischandra, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 
Computer101Commented:
Comment from expert accepted as answer

Computer101
E-E Admin
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 18
  • 8
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now