Thanks, I got it working using Peter's method, code is below for
anyone else who is searching for a way to do this (MS Access VBA).
The workspace selected is copied to the local drive and the two lines
"Set Map" and "Center (x,y)" are written to the end of it (X and Y
come from my form).
Workspace file is then opened in Proviewer and it works perfectly!
Unfortunately it opens a new version of Proviewer each time, but I
will work on that.
Code snippet below:
---------------------------
'copy workspace file to c:\, will overwrite it if exists
Dim fs As Object
Dim oldPath, newPath, strWORFILE As String
oldPath = " c:\temp " 'Folder file is located in
newPath = "C:\temp\temp" 'Folder to copy file to
strWORFILE = "Proviewer_Base.WOR" 'name of file to copy
Set fs = CreateObject("Scripting.FileSystemObject")
fs.CopyFile oldPath & "\" & strWORFILE, newPath & "\" & strWORFILE
'copy file to new path location
Set fs = Nothing
'define new file
strFileName = newPath & "\" & strWORFILE
'edit file
Open strFileName For Append As #1
'write to file contents
'sets map to center from Easting/Northing for address selected on form
strFile = "Set map"
Print #1, strFile
strFile = "Center (" & strX & ", " & strY & ")"
Print #1, strFile
Close #1
'Open temporary workspace in Proviewer/MapInfo
PVPath = "C:\Program Files\MapInfo\Proviewer\Mapinfor.exe"
retval = Shell(PVPath & " " & strFileName, vbNormalFocus)
If retval = 0 Then
MsgBox "An Error has occurred opening Proviewer", vbOKOnly,
"Proviewer Error!"
Exit Sub
End If
---------------------
Might not be the most elegant but it works.
Cheers
Grant