Sub Main Debug.Print "----- ";Time;" -----" On Error GoTo createnew Set surf = GetObject(,"Surfer.Application") On Error GoTo 0 GoTo skipnew createnew: Set Surf = CreateObject("Surfer.Application") Set plotdoc1 = surf.Documents.Add skipnew: surf.Visible = True Set plotdoc1 = surf.Documents(1) Set plotwin1 = surf.Windows(1) Set shapes1 = plotdoc1.Shapes imagefile1 = GetFilePath(,"tif;tfw",,"Specify TIF or TFW") extension = LCase(Right(imagefile1,3)) Select Case extension Case "tif" worldfile1 = Left(imagefile1, Len(imagefile1)-2) + Right(imagefile1,1) +"w" Case "tfw" worldfile1 = imagefile1 imagefile1 = Left(imagefile1, Len(imagefile1)-3) + "tif" Case Else MsgBox("Must be TIF or TFW 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 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 '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