Discussion Locked

Writing to Excel from Visual Basic 5.0

0 helpful
3 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I would like to write to an existing Excel file from Visual Basic 5.0. However, if this file does not exist, I would like to create one with that name. I do not want to actually open or view Excel though. How do I do this? Please include references needed and error checking. Thanks.

3 replies

by luke tennant

use createObject("path/file")
ie: set exlobj = createObject("path/file.xls")

If the file dosen't exist it will be created. The file is not displayed, but you can now iteract with it using vb/vba.

I have cut and pasted the MSDN refrence for createObject (vb ref) below:-

CreateObject Function

Creates and returns a reference to an ActiveX object.

Syntax

CreateObject(class,[servername])

The CreateObject function syntax has these parts:

Part Description
class Required; Variant (String). The application name and class of the object to create.
servername Optional; Variant (String). The name of the network server where the object will be created. If servername is an empty string (""), the local machine is used.

This discussion is closed to new replies.