'TifTfwLf.bas Sub Main Debug.Print "----- ";Time;" -----" Dim x() As String On Error Resume Next Set surf = GetObject(,"surfer.application") If Err <> 0 Then Set surf = CreateObject("surfer.application") surf.Documents.Add(srfDocPlot) End If On Error GoTo 0 surf.Visible = True Set plotdoc1 = surf.ActiveDocument Set plotwin1 = surf.ActiveWindow Set shapes1 = plotdoc1.Shapes imagefile1 = GetFilePath(,"tif;tfw;jpg;jgw;png;pgw",,"Specify bitmap or world file") extension = LCase(Right(imagefile1,3)) Select Case extension Case "tif","jpg","png" worldfile1 = Left(imagefile1, Len(imagefile1)-2) + Right(imagefile1,1) +"w" Case "tfw" worldfile1 = imagefile1 imagefile1 = Left(imagefile1, Len(imagefile1)-3) + "tif" Case "jgw" worldfile1 = imagefile1 imagefile1 = Left(imagefile1, Len(imagefile1)-3) + "jpg" Case "pgw" worldfile1 = imagefile1 imagefile1 = Left(imagefile1, Len(imagefile1)-3) + "png" Case Else MsgBox("Must be TIF, TFW, JPG, or JGW extension"+vbCrLf+"Aborting script.",vbOkOnly) End End Select If Dir(worldfile1) = "" Then MsgBox("Could not find "+worldfile1+"."+Chr(10) + _ "Aborting script.", vbOkOnly, "File Not Found.") End End If Set mapframe1 = shapes1.AddBaseMap(imagefile1) Set base1 = mapframe1.Overlays("base") 'Get image dimensions. xmin1 = base1.xMin xmax1 = base1.xMax ymin1 = base1.yMin ymax1 = base1.yMax 'Read World file. Open worldfile1 For Input As #1 Line Input #1, xpixelwidth Debug.Print xpixelwidth If InStr(xpixelwidth,Chr(10)) = 0 Then Line Input #1, xrotation Line Input #1, yrotation Line Input #1, ypixelwidth 'neg of y pixel size. Line Input #1, xmin2 Line Input #1, ymax2 Else 'MsgBox("Edit "+worldfile1+" in Notepad to remove linefeeds.", _ ' vbOkOnly,"Missing Carriage Returns") x() = Split (xpixelwidth,vbLf) 'Type mismatch error xpixelwidth = x(0) xrotation = x(1) yrotation = x(2) ypixelwidth = x(3) xmin2 = x(4) ymax2 = x(5) End If 'Ignore translation and rotation for now 'xmin2 = xmin2 - ( xmax2 = xmin2 + ((xmax1 - xmin1) * xpixelwidth) ymin2 = ymax2 - ((ymax1 - ymin1) * -(ypixelwidth)) Debug.Print "xMin: ";xmin2; " xMax: ";xmax2; " yMin: ";ymin2; " yMax: ";ymax2 base1.SetImageLimits(xMin:=xmin2,xMax:=xmax2,yMin:=ymin2,yMax:= ymax2) plotwin1.Zoom(srfZoomFitToWindow) End Sub