| Home | Previous Lesson: Opening a File In a OLE Control Next Lesson: Insert Class In the OLE Control |
Another flavor of Open() allows you open a sub-storage into the OLE control. OLE supports storages and sub-storages. In simple terms, Storages are like DOS file structures. From the operating file structure, the storage file looks like a single file, however, you can have lot other sub-storages within a storage, even though you can't see from the operating system. To open a sub-storage in the OLE control, first we need to open the storage file into a variable of type OLEStorage and you can use that variable as the argument for the Open() for the OLE control.
To see it in the action, run the application. Select 'Module > OLE Control Examples' menu option. Click on the 'Open SubStorage' CommandButton.
The following example, opens the storage file OLE_TEST.OLE into the ole storage file iOLEStorage. The next line opens OLE_TEST.XLS which is stored in the storage file OLE_STORAGE.OLE into the OLE control. More on storages, sub-storages and streams in the next session.
Integer lResult, I
lResult = iOLEStorage.Open( "c:\workdir\ole_test.ole" )
lResult = ole_1.Open( iOLEStorage, "ole_test.xls" )
If lResult <> 0 Then
MessageBox( "File Open Error", lResult )
Destroy iOLEStorage
Return -1
Else
MessageBox( "Open", "Opened Successfully. " + &
"Double-click on the OLE control " + &
" to edit the Excel spread sheet" )
End If
| Home | Previous Lesson: Opening a File In a OLE Control Next Lesson: Insert Class In the OLE Control |