Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Lotus123 In visual basic 6

Status
Not open for further replies.

sktk6

Programmer
May 9, 2003
3
US
Im new to vb6 Im trying to start lotus123 through a program I am writing and seem to be having a lot of difficulty. Any help would be greatly appreciated.
 
Do you want to Shell it or automate it and code against the 1-2-3 object model? Exactly what difficulty are you experiencing? Which version of 1-2-3?

Paul Bent
Northwind IT Systems
 
The goal of this particular portion of the program is to open a lotus file (.123 file format) and save it as an excel 2002 file. Its lotus millenium edition v9. Sinc excel 2002 doesnt support the .123 file format I have to do it this way. Doesnt matter how I go about it. I just cant figure out how to do it
 
1-2-3 is a single instance app so you need to take into account whether it's running or not when you automate it and only close it if not already running. Here's a rough idea to get you started:
Code:
Dim objApp As Object '1-2-3 application
Dim objDoc As Object '1-2-3 workbook
Dim blnOpen As Boolean 'Flag if 1-2-3 already running

'Check if 1-2-3 is already running
On Error Resume Next
Set objDoc = GetObject("", "Lotus123.Workbook")
'Restore error handling. Errors from here on
'are reported up the call stack
On Error Goto 0

If objDoc Is Nothing Then
 '1-2-3 is not running, open it by creating a new document
 Set objDoc = CreateObject("Lotus123.Workbook")
Else
 '1-2-3 is running, set the flag
 blnOpen = True
End If
'Get the reference to the application object
Set objApp = objDoc.Parent
'It's optional to make it visible
If Not blnOpen Then
 objApp.Visible = True
End If
'Open the 1-2-3 workbook
Set objDoc = objApp.OpenDocument( _
"xyz.123", "x:\mypath")
'Save the workbook as .xls
objDoc.SaveAs "xyz.xls", "X:\mypath", "Microsoft Excel 97-2000 Workbook (XLS)"

'Close the doc
If blnOpen Then
 '1-2-3 was running, just close the new doc
 objDoc.Close
Else
 'We started 1-2-3 so close it
 'There should be one untitled doc
 'and the new doc open
 'In 1-2-3, closing the last doc also closes the app.
 'If you close all docs then use Quit on the app there's a run-time error
 For Each objDoc in objApp.Documents
  objDoc.Close False
 Next
End If

'Release object references
Set objDoc = Nothing
Set objApp = Nothing
Unfortunately rel 9 is a bit vague. There are 9.0, 9.1, 9.5, 9.6, 9.7 and 9.8 and the level of support for xls versions will vary. I've just looked at 9.8 and the latest filter is for "Microsoft Excel 97-2000 Workbook (XLS)"

You can check your version of 1-2-3: from the Help menu - Help Topics - Index tab. Type cl to hit Classes (LotusScript) and display it. Select the Classes link and select Document in the next window. Click the Class Members button and select SaveAs in the second window. This will display detailed help in the first window and you can see which xls types are supported. They should also correspond to the file types displayed when you select Save As from the 1-2-3 File menu.

Paul Bent
Northwind IT Systems
 
Thanks very much for the help, I'll let ya know if it works.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top