Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

print problem

Posted on 2002-07-15
30
Medium Priority
?
231 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
[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
  • 18
  • 8
  • 2
  • +2
30 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 7154361
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
ID: 7154489
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
ID: 7154508
Don't use an .EndDoc as this will cause a form feed to be sent to feed the sheet through the printer.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 3

Expert Comment

by:PNJ
ID: 7154514
"printer.weight=500"

do you mean Printer.Width ?
0
 

Author Comment

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

Author Comment

by:prasadharischandra
ID: 7154539
my paper is continus paper
0
 

Author Comment

by:prasadharischandra
ID: 7154550
my paper is continus paper
0
 

Author Comment

by:prasadharischandra
ID: 7154561
my paper is continus paper
0
 
LVL 3

Expert Comment

by:PNJ
ID: 7154571
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
ID: 7154593
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
ID: 7154630
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
ID: 7154747
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
ID: 7154765
error on
Printer.PaperSize = vbPRPSUser
please help me
0
 

Author Comment

by:prasadharischandra
ID: 7154783
error on
Printer.PaperSize = vbPRPSUser
please help me
0
 

Author Comment

by:prasadharischandra
ID: 7154789
error on
Printer.PaperSize = vbPRPSUser
please help me
0
 

Author Comment

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

Expert Comment

by:PNJ
ID: 7154811
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
ID: 7154880
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
ID: 7154892
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 400 total points
ID: 7154908
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
ID: 7155066
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
ID: 7155460
Yup, give that a go.
0
 

Author Comment

by:prasadharischandra
ID: 7173372
still not working
0
 
LVL 3

Expert Comment

by:PNJ
ID: 7173676
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
ID: 7173814
it's not workig stiill
0
 

Author Comment

by:prasadharischandra
ID: 7184249
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
ID: 7184262
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
ID: 7184276
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
ID: 8012287
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
ID: 8096024
Comment from expert accepted as answer

Computer101
E-E Admin
0

Featured Post

Enroll in October's Free Course of the Month

Do you work with and analyze data? Enroll in October's Course of the Month for 7+ hours of SQL training, allowing you to quickly and efficiently store or retrieve data. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

650 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