Meridian API Sample Code

' Get current path
Set FSO = CreateObject("Scripting.FileSystemObject")
strPath = FSO.GetFile(Wscript.ScriptFullName).ParentFolder & "\"
Set FSO = Nothing

' Set the file to print variable with the full path
fileToPrint = strPath & "word.doc"

' Instantiate Object
Set oMER = CreateObject("APMeridian.Object")

' START - Call the functions needed for a remote print job

' Tell the API how to reach the Meridian Server
oMER.StartRemoteClient "10.0.0.121",  58585

' Must use either SetUniuqeInput or SetProcessAndThread
' Here we are using SetUniqueInput, as the print job is
' from Microsoft Word, Word will add "Microsoft Word - "
' to the print job so we need to let meridian know using
' UniqueInputPrefix
oMER.UniqueInputPrefix = "Microsoft Word - "

' Call SetUniqueInput with the full path to the input
' set to true as we are not worried about printing this
' same named file at the same time
oMER.SetUniqueInput fileToPrint, true

' END ----------------------------------------------------

' Path and filename of the created PDF
oMER.OutputDirectory = strPath
oMER.NewDocumentName = "Output.pdf"
 
' Set the ModelPrinter to the remote Meridian printer
' This printer must be added locally to the remote system
oMER.ModelPrinter = "\\10.0.0.121\Meridian"
 
' Start the print job
varReturn = oMER.StartPrinting()
If varReturn <> 0 Then
  Error "StartPrinting"
End If
 
' Automate Word to print a document to the ModalPrinter property
Set objWord = CreateObject("Word.Application")
objWord.DisplayAlerts = False
Set objDoc = objWord.Documents.Open((fileToPrint), False, True)
Set objWordDialog = objWord.Dialogs(97)
objWordDialog.Printer = oMER.ModelPrinter
objWordDialog.DoNotSetAsSysDefault = 1
objWordDialog.Execute
objDoc.PrintOut False
objDoc.Close False
objWord.Quit False
Set objWordDialog = Nothing
Set objDoc = Nothing
Set objWord = Nothing
 
' Let Meridian know that the print job has completed
oMER.StopPrinting
 
' Wait(seconds) for job to complete
varReturn = oMER.Wait(30)
If varReturn <> 0 Then
  Error "Wait"
End If

Set oMER = Nothing

Msgbox "Done!"

' Error Handling
Sub Error(Method)
	Msgbox "'" & Method & "' failed with a '" & varReturn
End Sub