'TifTfwExport3.bas 'Export TIF and TFW. TB - 07 nov 02 ' Added Selected Objects Only to export. TB - 10 dec 02. ' Added Round to make number of pixels and integer. MB - 25 Aug 03. Sub Main exportdpi = 100 Debug.Print "----- ";Time;" -----" On Error GoTo errormsg Set surf = GetObject(,"Surfer.Application") On Error GoTo 0 Set plotdoc1 = surf.ActiveDocument 'Set mapframe1 = plotdoc1.Shapes("Map") If plotdoc1.Selection.Count = 0 Then GoTo errormsg Set mapframe1 = plotdoc1.Selection(1) If mapframe1.Type <> srfShapeMapFrame Then GoTo errormsg Debug.Print mapframe1;" selected" For Each axis In mapframe1.Axes axis.ShowLabels = False axis.MajorTickType = srfTickNone axis.MinorTickType = srfTickNone axis.AxisLine.Style="Invisible" Next axis 'Remove any transform or stretching mapframe1.Width = mapframe1.xLength mapframe1.Height = mapframe1.yLength tiffile1 = GetFilePath(,"tif",surf.Path+"\samples\", _ "Enter TIF File Name",2) If Right(tiffile1,3) <> "tif" Then tiffile1 = tiffile1+".tif" Debug.Print "TIF extension added to export file name." +tiffile1 End If With mapframe1 widthpixels = Round(.Width*exportdpi) heightpixels = Round(.Height*exportdpi) xres = (.xMax - .xMin)/(widthpixels) yres = (.yMax - .yMin)/(heightpixels) plotdoc1.Export(tiffile1,SelectionOnly:=True, _ options:= "width=" + Trim(Str(widthpixels)) + _ ",height=" + Trim(Str(heightpixels))) End With tfwfile1 = Left(tiffile1,Len(tiffile1)-3)+"tfw" Debug.Print "Writing ";tfwfile1 Open tfwfile1 For Output As #1 Print #1,xres Print #1,0 Print #1,0 Print #1,-yres Print #1,mapframe1.xMin Print #1,mapframe1.yMax Close #1 End errormsg: MsgBox("Start Surfer, select the map to export, then run the script.", _ "Unable to Export Map") End Sub