Solved

print problem

Posted on 2002-07-15
30
182 Views
Last Modified: 2010-05-02
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
Comment
Question by:prasadharischandra
  • 18
  • 8
  • 2
  • +2
30 Comments
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
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
 

Author Comment

by:prasadharischandra
Comment Utility
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
 
LVL 43

Expert Comment

by:TimCottee
Comment Utility
Don't use an .EndDoc as this will cause a form feed to be sent to feed the sheet through the printer.
0
 
LVL 3

Expert Comment

by:PNJ
Comment Utility
"printer.weight=500"

do you mean Printer.Width ?
0
 

Author Comment

by:prasadharischandra
Comment Utility
no paper width
and how to stop reject paper
i know only enddoc
0
 

Author Comment

by:prasadharischandra
Comment Utility
my paper is continus paper
0
 

Author Comment

by:prasadharischandra
Comment Utility
my paper is continus paper
0
 

Author Comment

by:prasadharischandra
Comment Utility
my paper is continus paper
0
 
LVL 3

Expert Comment

by:PNJ
Comment Utility
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
 
LVL 3

Expert Comment

by:PNJ
Comment Utility
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
 
LVL 3

Expert Comment

by:PNJ
Comment Utility
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
 

Author Comment

by:prasadharischandra
Comment Utility
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
 

Author Comment

by:prasadharischandra
Comment Utility
error on
Printer.PaperSize = vbPRPSUser
please help me
0
 

Author Comment

by:prasadharischandra
Comment Utility
error on
Printer.PaperSize = vbPRPSUser
please help me
0
 

Author Comment

by:prasadharischandra
Comment Utility
error on
Printer.PaperSize = vbPRPSUser
please help me
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:prasadharischandra
Comment Utility
error on
Printer.PaperSize = vbPRPSUser
please help me
0
 
LVL 3

Expert Comment

by:PNJ
Comment Utility
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
 

Author Comment

by:prasadharischandra
Comment Utility
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
 

Author Comment

by:prasadharischandra
Comment Utility
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
 
LVL 3

Accepted Solution

by:
PNJ earned 100 total points
Comment Utility
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
 

Author Comment

by:prasadharischandra
Comment Utility
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
 
LVL 3

Expert Comment

by:PNJ
Comment Utility
Yup, give that a go.
0
 

Author Comment

by:prasadharischandra
Comment Utility
still not working
0
 
LVL 3

Expert Comment

by:PNJ
Comment Utility
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
 

Author Comment

by:prasadharischandra
Comment Utility
it's not workig stiill
0
 

Author Comment

by:prasadharischandra
Comment Utility
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
 

Author Comment

by:prasadharischandra
Comment Utility
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
 

Author Comment

by:prasadharischandra
Comment Utility
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
 
LVL 49

Expert Comment

by:DanRollins
Comment Utility
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
 
LVL 1

Expert Comment

by:Computer101
Comment Utility
Comment from expert accepted as answer

Computer101
E-E Admin
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

762 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

9 Experts available now in Live!

Get 1:1 Help Now