|
The article below may help. Manuel ----- Plagiarized Text Follows: ----------> Print Word Documents from an AS/400 by Herman Van der Staey Article Information Article ID: 6311 Pub: iSeries NEWS Dept: Tech Corner Date: July 01, 1999 You can use the AS/400's RUNRMTCMD command to print PC documents from your AS/400. I wrote a Visual Basic (VB) 6.0 program, PRINTDOC.EXE, that prints documents from a PC application, such as Microsoft Word or Excel, running on a PC with Client Access for Windows 95/NT (V3R1M2 or higher) associated with the program (Figure A). PRINTDOC.EXE accepts one parameter - the name of the document you want to print. For example, if PRINTDOC.EXE is in C:\PROG and Word document MYWORD.DOC is in C:\DATA, you'd execute RUNRMTCMD as follows: RUNRMTCMD CMD('C:\PROG\PRINTDOC.EXE + C:\DATA\MYWORD.DOC') + RMTLOCNAME('xxx.xxx.xxx.xxx' *IP)+ RMTUSER(pc user ID) + RMTPWD('password') (xxx.xxx.xxx.xxx is the IP address or host name of the target PC, pc user ID is the user ID for the target PC, and password is the target PC user's password). Because Windows NT passwords are case sensitive, you should place single quotes around the password to preserve the case. If you wanted to print an Excel worksheet, you'd specify a file with an .XLS instead of a .DOC extension. Note that you must start the Client Access Incoming Remote Command NT service or daemon program (on non-NT systems) on the target PC to use RUNRMTCMD. (For more information about RUNRMTCMD and the Incoming Remote Command service/daemon, see the IBM Redbook Inside AS/400 Client Access, SG24-4748.) PRINTDOC.EXE uses the Windows ShellExecute API to open or print the Microsoft application file (.DOC or .XLS) without requiring the user to specify the name of the application associated with the file. Note that although PRINTDOC.EXE works with .DOC and .XLS files, it doesn't work for all file types. For more information about the ShellExecute API, see Microsoft Knowledge Base article Q170918 at http://support.micro soft.com/support/kb/articles/q170/9/18.asp. You can download a self-extracting zip file containing all the files needed to install PRINTDOC.EXE from http://www.news400.com. After you decompress the file, you can easily install PRINTDOC.EXE, including all needed dynamic link library (DLL) files, using a SETUP.EXE program that you create with VB 6.0's Deployment Wizard. Tip provided by Herman Van der Staey, systems engineer at Delcredere - Ducroire, the Belgian Export Credit Agency, in Brussels, Belgium. Contact him at h_vanderstaey@ondd.be. Figure 1 ------------ Attribute VB_Name = "Module1" ' PRINTDOC.EXE version 1.03 1999/05/12 ' ------------ ' ' This program starts the application associated with ' a given document extension and prints the document ' in the background ' ' PRINTDOC.EXE accepts one parameter: the name of the document ' you want to print. ' ' Errors are written to the file ERRLOG.TXT Option Explicit Private Declare Function ShellExecute Lib "shell32.dll" Alias _ "ShellExecuteA" (ByVal hwnd As Long, ByVal lpszOp As _ String, ByVal lpszFile As String, ByVal lpszParams As String, _ ByVal lpszDir As String, ByVal FsShowCmd As Long) As Long Private Declare Function GetDesktopWindow Lib "user32" () As Long Const SW_SHOWNORMAL = 1 Const SE_ERR_FNF = 2& Const SE_ERR_PNF = 3& Const SE_ERR_ACCESSDENIED = 5& Const SE_ERR_OOM = 8& Const SE_ERR_DLLNOTFOUND = 32& Const SE_ERR_SHARE = 26& Const SE_ERR_ASSOCINCOMPLETE = 27& Const SE_ERR_DDETIMEOUT = 28& Const SE_ERR_DDEFAIL = 29& Const SE_ERR_DDEBUSY = 30& Const SE_ERR_NOASSOC = 31& Const ERROR_BAD_FORMAT = 11& Function prtDoc(DocName As String) As Long Dim Scr_hDC As Long Scr_hDC = GetDesktopWindow() prtDoc = ShellExecute(Scr_hDC, "print", DocName, _ "", App.Path, SW_SHOWNORMAL) End Function Sub Main() Dim r As Long, msg, logfile, logtext As String Dim FileNumber As Integer r = prtDoc(Command$) If r <= 32 Then 'There was an error Select Case r Case SE_ERR_FNF msg = "File not found" Case SE_ERR_PNF msg = "Path not found" Case SE_ERR_ACCESSDENIED msg = "Access denied" Case SE_ERR_OOM msg = "Out of memory" Case SE_ERR_DLLNOTFOUND msg = "DLL not found" Case SE_ERR_SHARE msg = "A sharing violation occurred" Case SE_ERR_ASSOCINCOMPLETE msg = "Incomplete or invalid file association" Case SE_ERR_DDETIMEOUT msg = "DDE Time out" Case SE_ERR_DDEFAIL msg = "DDE transaction failed" Case SE_ERR_DDEBUSY msg = "DDE busy" Case SE_ERR_NOASSOC msg = "No association for file extension" Case ERROR_BAD_FORMAT msg = "Invalid EXE file or error in EXE image" Case Else msg = "Unknown error" End Select ' Log the error message in file ERRLOG.TXT FileNumber = FreeFile ' get unused file number logfile = App.Path + "\ERRLOG.TXT" Open logfile For Append Access Write As #FileNumber Print #FileNumber, Format(Now, "yyyy/mm/dd hh:mm:ss"); _ Spc(3); msg; Spc(3); Command$ Close #FileNumber End If End Sub -----Original Message----- From: Taylor, Mark W [mailto:MarkWTaylor@eaton.com] Sent: Tuesday, September 10, 2002 2:44 PM To: 'mapics-l@midrange.com' Subject: Re: User Exit after Packing Slip? As far as the Word document, I can't help you. But I have some information for you on the User Exit at Pack List time. The User Exit name is UMBSHP3R If you look at the documentation for that user exit it will say that it receives 4 parameters: Company Number, Header Type, Order Number, and Shipment Number.... But it doesn't (as I had to learn the hard way) The parms only contain the Company Number, and the Shipment Number. You have to chain out to the Shipment file MBDDRES8 with the Company Number and Shipment number to get to the Order Number. Hopfully this will save you some trouble once you figure out the issue with the Word document. Mark Taylor _______________________________________________ This is the MAPICS ERP System Discussion (MAPICS-L) mailing list To post a message email: MAPICS-L@midrange.com To subscribe, unsubscribe, or change list options, visit: http://lists.midrange.com/cgi-bin/listinfo/mapics-l or email: MAPICS-L-request@midrange.com Before posting, please take a moment to review the archives at http://archive.midrange.com/mapics-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.