Is there a way to create text with different fonts or font styles within the same text box from a MapViewer automation script?

Yes, you can create text with different font styles via automation. To do so, the Math Text commands must be used. Below is a script with some examples.


To run this script:

  1. Copy the text below, from the Sub Main start line to the End Sub end line.
  2. In a Windows Explorer window, navigate to C:\Program Files\Golden Software\MapViewer 8\Scripter.
  3. Double click on Scripter.exe to launch Scripter.
  4. Press Ctrl+A to select all of the existing lines.
  5. Press Ctrl+V to paste your copied script over top of these existing lines.
  6. Click Script | Run to run the script.


Sub Main

Dim mvApp, Plot As Object
Set mvApp = CreateObject("MapViewer.Application")
mvApp.Visible = True

'Opens a new plot window
Set Plot = mvApp.Documents.Add(mvDocPlot)

'Sets the Shapes variable
Set Shapes=Plot.Layers.ActiveLayer.Shapes

'Add a text object that contains two lines
Shapes.AddText(2,7,"This is a text block" + vbCrLf + "with two rows.")

'Add another text object that shows how to insert a symbol
Shapes.AddText(2,6,"This is a bullet \a183 in the middle of text")

'This example shows how to include bold , italics and strikethrough text
Shapes.AddText(2,5,"This is {\b bold}, {\i italic} and {\strike strikethrough} text.")

'This example shows how to insert the current date/time
Shapes.AddText(2,4,"This is the date: \date . This is the time: \time .")

'Insert user input data Min = "10" Max = "25"

Shapes.AddText(2,3,"Custom text from user input data: [" + Min + "] to [" + Max + "]")

'Change font in text

Shapes.AddText(2,2,"This is some text {\f" + Chr(34) + "Wingdings" + Chr(34) + " text} in a different font than the rest.")

End Sub



For more information and other math text commands, see the Math Text Instruction Syntax page in MapViewer's online help. This page gives information about math text syntax. Click on the "math text instructions" link in the page for other math text commands.


Updated February 4, 2019

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


Please sign in to leave a comment.