borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Next Topic (code to create short cut in startup for an exe) New Topic New Poll Post Reply
AndreaVB Forum : VB General : Need some help
Poster Message
Lottie
Level: Trainee

Registered: 19-11-2007
Posts: 1

icon Need some help

Kindly help me. I want to create a simple application that will send a plot file (microstation plot file) to a network plotter or printer. I VB6, i am just an intermediate. I have 2 options. First is to use list box and a command button. The list box will be populated by the plotfile names (i.e. AAA.000, 123.000 etc.) and then send all the plotfile to printer/plotter. I can do the design but i do not know how to send them to printer/plotter. The 2nd option is by running a batch file. This is fine but a bit tedious. Everytime i print a plotfile, I have to go to the msdos prompt and run the batch file. I just want to automate the process a bit. My problem with this is i don't know how to run and external program like batch file from VB6. My batch file to send a plotfile to a printer is copy %1.000 \\tfsspsrv\PCS1. The MSDN help does not provide a good example. Although i think the first option is a bit more complicated I would appreciate if both options can be done. I can do all the design for this. I just want to know how to send the plotfile to a printer or plotter.

Thank you for your help.

Lottie

19-11-2007 at 09:28 AM
View Profile Send Email to User Show All Posts | Quote Reply
aredz
Level: Protégé


Registered: 08-12-2007
Posts: 7
icon Re: Need some help

just a question... is this your batch file code?.. "copy %1.000 \\tfsspsrv\PCS1" ... is %1.000 your plot file?...

I don't think if I'm right... is your plot file the one you are going to print on your network printer?.. here's my solution... only for calling the external batch file using your batch code above.. I've used somewhat similar on my previous program...

%1.000 = your plot file
\\tfsspsrv = your network computer
\PCS1 = your network computer drive

here's the simplest code.. pertaining the code you only said..

NOTE: put this code inside your command button
(this code automatically generates a batch file and then calls it automatically)

Open App.Path & "\mybatch.bat" For Output As #1
Print #1, ("copy " & Chr(37) & "1.000 \\tfsspsrv\PCS1")
Close #1
Shell App.Path & "\mybatch.bat"

here's something I figured out for you...

NOTE: %1.000 will only be the plot file to be used in this coding passing through different network computers
(this code automatically generates a batch file and then calls it automatically)

Private Sub cmdGo_Click()
Dim pcnamecheck As String
If txtpcname <> "" Then
    pcnamecheck = Left(txtpcname.Text, 2)
    If pcnamecheck = "\\" Then
        Open App.Path & "\mybatch.bat" For Output As #1
        Print #1, ("copy " & Chr(37) & "1.000 " & txtpcname.Text & "\" & txtdrive.Text)
        Close #1
        Shell App.Path & "\mybatch.bat"
   Else
    txtpcname = "\\" & txtpcname
    cmdGo_Click
    End If
End If
End Sub

OBJECTS:
txtpcname.text = textbox to input network computer name
txtdrive.text = textbox to input drive of network computer name
cmdGo = command button to execute program

NOTE: again..   ...
if you want to change a plot file name everytime you want to click the button create another textbox and figure out the code to be used.. it's easy to understand.. coded this to the extent that anyone can figure it out... and.. I love using batch files and the shell command...   ... hihi... hope this code helped you on your problem...  

22-12-2007 at 06:32 AM
View Profile Send Email to User Show All Posts | Quote Reply
nonie
Level: Trainee

Registered: 25-08-2005
Posts: 3
icon Re: Need some help

Thank you for the reply. Yes, %1.000 is a plot file generated by microstation. It can be any program that can generate plot file (i.e. 1.plt - Autocad). I will try to use the code you provided. What i have in mind is something like this. A text box and a command button. When the user click the command button, a loop is executed. The loop is like this:
for i = 1 to val(textbox1)
    run "c:\prt\print.bat "; i
next i
All the plot file must have a file name of 1.000, 2.000, 3.000 etc. If autocad plot file then 1.plt, 2.plt, 3.plt etc. The reason for this has something to do with the for next loop. When the counter is 1, get the 1.000 or 1.plt file, then run the batch file.
My batch file is copy %1.000 \\tfsspsrv\PCS1. When the counter becomes 2, get 2.000 or 2.plt file, then run again the batch file repeat again until all the plot file has been sent. You may notice that there are some hard coding here (ie c:\prt\print.bat and also i am forcing the user to name or rename their plot files to 1.00, 2.00, 3.00 etc. So my only problem here is how to put this code run "c:\prt\print.bat "; i
in proper VB code. the rest i can do. Our network printer has a PIN no. in order to print to it. I hope this is clear.

Thank you.

Lottie

31-12-2007 at 03:27 AM
View Profile Send Email to User Show All Posts | Quote Reply
aredz
Level: Protégé


Registered: 08-12-2007
Posts: 7
icon Re: Need some help

no problem...

please post your batch file codes and I'll try to recode it...

the content of print.bat ....

later...  

08-01-2008 at 05:12 AM
View Profile Send Email to User Show All Posts | Quote Reply
nonie
Level: Trainee

Registered: 25-08-2005
Posts: 3
icon Re: Need some help

Thank You. Here is my batch file configuration: Print.bat

copy %1.plt \\ccc-printserver\TECHPTR1

This is the batch file that should be called by the VB "Shell" or "Run" statement. Our printer is an HP Laserjet 9000mfp model and is being access by an assigned pin number.

Thank you.

Nonie

11-01-2008 at 06:06 AM
View Profile Send Email to User Show All Posts | Quote Reply
aredz
Level: Protégé


Registered: 08-12-2007
Posts: 7
icon Re: Need some help

here's the code:

for i = 1 to val(textbox1.text)

Open App.Path & "\print.bat" For Output As #1
Print #1, ("copy " & Chr(37) & i & ".plt" & "\\ccc-printserver\TECHTR1")
Close #1
Shell App.path & "\print.bat"

next i

NOTE:

the line...
Print #1, ("copy " & Chr(37) & i & ".plt" & "\\ccc-printserver\TECHTR1")

is for printing all the plot files...

14-01-2008 at 08:58 AM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : VB General : Need some help
Next Topic (code to create short cut in startup for an exe) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2008 Andrea Tincaniborder