Syntax 4: For saving an OLE storage object to a file
Description
Saves an OLE storage object to a file. If OLE controls have opened
the OLE storage object, this syntax of SaveAs puts them in a saved state
too.
Applies to
OLE storage objects
Syntax
|
1 |
olestorage.SaveAs (OLEtargetfile ) |
|
Argument |
Description |
|---|---|
|
olestorage |
The name of an object variable of type OLEStorage |
|
OLEtargetfile |
A string specifying the name of a new OLE storage file. |
Return value
Integer.
Returns 0 if it succeeds and one of the following negative values
if an error occurs:
-1 — The storage is not open
-2 — The storage name is invalid
-3 — The parent storage is not open
-4 — The file already exists
-5 — Insufficient memory
-6 — Too many files open
-7 — Access denied
-9 — Other error
If any argument’s value is null, SaveAs returns null.
Usage
The Open function establishes a connection between a storage file
and a storage object, or a storage file or object and an OLE control.
The Save function uses this connection to save the OLE data.
When you call SaveAs for a storage object, it closes the current
connection between the storage object and a file and creates a new file
for the storage object’s data.
For information about the structure of storage files, see the
Open function.
Examples
This example saves the storage object stg_stuff to the file
MYSTUFF.OLE. Olest_stuff is an instance variable:
|
1 2 |
integer result result = stg_stuff.SaveAs("c:olemystuff.ole") |
This example opens a substorage in one file and saves it in
another file. An OLE storage file called MYROOT.OLE contains several
substorages; one is called sub1. To open sub1 and save it in another
file, the example defines two storage objects: stg1 and stg2. First
MYROOT.OLE is opened into stg1. Next, sub1 is opened into stg2. Finally,
stg2 is saved to the new file MYSUB.OLE. Just as when you open a word
processing document and save it to a new name, the open object in stg2
is no longer associated with MYROOT.OLE; it is now connected to
MYSUB.OLE:
|
1 2 3 4 5 6 7 |
olestorage stg1, stg2 stg1 = CREATE OLEStorage stg2 = CREATE OLEStorage stg1.Open("myroot.ole") stg2.Open("sub1", stg1) stg2.SaveAs("mysub.ole") |
See also