Follow

How can I use a MapViewer script to print many files to specific file names without manually entering them all?

This article contains a sample script for printing multiple documents to filenames that are stored in an input text file.


To run this script:

  1. Copy the script below, or click here to download the BAS file: Print.BAS.
  2. Download the attached InputFiles.Txt file and put it in the C:\Program Files\Golden Software\MapViewer 8\Samples directory.
  3. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\MapViewer 8\Scripter.
  4. Double click on Scripter.exe to launch Scripter.
  5. Press Ctrl+A to select all of the existing lines then press Delete.
  6. If you copied this script, press Ctrl+V to paste it into Scripter. If you downloaded it, click File | Open, select the BAS file from your downloads directory, and click Open.
  7. Click Script | Run to run the script.
     

*********

''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Print.BAS
' Copyright (C) Golden Software Inc. 1992-2015
'
' This sample demonstrates how to print multiple documents with their
' filenames stored in an input file.
'
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Sub Main

   'Creates an instance of the MapViewer Application object
   'and assigns it to the variable named "MapViewerApp"
   Set MapViewerApp = CreateObject("MapViewer.Application")

   'Makes the application main window visible
   MapViewerApp.Visible = True

   'Assigns the location of the samples folder to the variable "InPath"
   InPath$ = MapViewerApp.ModuleFolder + "samples\"

   'Open an input file that contains a filepath on each line,
   'and assign it to the file handle as #1
   Open InPath$ + "Scripts\InputFiles.txt" For Input As #1

   'Read a line
   Line Input #1,wks$

   While wks$ <> "EOF"
      'Open a map document, and assigns it to the variable named "doc"
      Set doc = MapViewerApp.Documents.Open(InPath$ + wks$)
      doc.PrintOut()
      doc.Close(mvSaveChangesNo)

      'Read the next line
      Line Input #1,wks$
   Wend

   'Close file handle
   Close #1

End Sub

 

Updated November 2, 2016

Was this article helpful?
0 out of 0 found this helpful
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.