home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.MDIForm mdiOLE
- BackColor = &H00C0C0C0&
- Caption = "OLE Container Control Example"
- ClientHeight = 6150
- ClientLeft = 285
- ClientTop = 885
- ClientWidth = 9030
- Height = 6840
- Icon = "MDIOLE.frx":0000
- Left = 225
- LinkTopic = "MDIForm1"
- Top = 255
- Width = 9150
- Begin VB.PictureBox StatusBar
- Align = 2 'Align Bottom
- Appearance = 0 'Flat
- BackColor = &H00C0C0C0&
- ForeColor = &H80000008&
- Height = 420
- Left = 0
- ScaleHeight = 390
- ScaleWidth = 9000
- TabIndex = 1
- Top = 5730
- Width = 9030
- Begin VB.Label lblStatus
- BackStyle = 0 'Transparent
- Caption = "Ready"
- Height = 240
- Left = 90
- TabIndex = 2
- Top = 90
- Width = 5505
- End
- End
- Begin VB.PictureBox Toolbar
- Align = 1 'Align Top
- Appearance = 0 'Flat
- BackColor = &H00C0C0C0&
- ForeColor = &H80000008&
- Height = 420
- Left = 0
- Negotiate = -1 'True
- ScaleHeight = 390
- ScaleWidth = 9000
- TabIndex = 0
- Top = 0
- Width = 9030
- Begin VB.Image imgTools
- Height = 330
- Index = 3
- Left = 1260
- Picture = "MDIOLE.frx":030A
- Top = 45
- Visible = 0 'False
- Width = 360
- End
- Begin VB.Image imgTools
- Height = 330
- Index = 2
- Left = 495
- Picture = "MDIOLE.frx":0494
- Tag = "Displays information about the linked OLE object"
- Top = 45
- Width = 360
- End
- Begin VB.Image imgHold
- Height = 315
- Left = 3195
- Top = 45
- Visible = 0 'False
- Width = 360
- End
- Begin VB.Image imgTools
- Height = 330
- Index = 1
- Left = 900
- Picture = "MDIOLE.frx":061E
- Top = 45
- Visible = 0 'False
- Width = 360
- End
- Begin VB.Image imgTools
- Height = 330
- Index = 0
- Left = 90
- Picture = "MDIOLE.frx":07A8
- Tag = "Terminates this application"
- Top = 45
- Width = 360
- End
- End
- Begin VB.Menu mnuFile
- Caption = "&File"
- NegotiatePosition= 1 'Left
- Begin VB.Menu mnuFileItems
- Caption = "E&xit"
- Index = 1
- End
- End
- Attribute VB_Name = "mdiOLE"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- '*********************************************************************
- ' MDIOLE.FRM - MDI Parent Form.
- '*********************************************************************
- Option Explicit
- Private StartedExcel As Long
- '*********************************************************************
- ' Saves the button image in imgHold, and inserts the down picture.
- '*********************************************************************
- Private Sub imgTools_MouseDown(Index As Integer, Button As Integer, _
- Shift As Integer, X As Single, Y As Single)
- imgHold.Picture = imgTools(Index).Picture
- imgTools(Index).Picture = imgTools(Index + 1).Picture
- End Sub
- '*********************************************************************
- ' Updates the status bar.
- '*********************************************************************
- Private Sub imgTools_MouseMove(Index As Integer, Button As Integer, _
- Shift As Integer, X As Single, Y As Single)
- UpdateStatus lblStatus, imgTools(Index).Tag
- End Sub
- '*********************************************************************
- ' Restores the graphic, and processes toolbar clicks.
- '*********************************************************************
- Private Sub imgTools_MouseUp(Index As Integer, Button As Integer, _
- Shift As Integer, X As Single, Y As Single)
- '*****************************************************************
- ' Restore the toolbar picture.
- '*****************************************************************
- imgTools(Index).Picture = imgHold.Picture
- '*****************************************************************
- ' Execute the appropriate toolbar action.
- '*****************************************************************
- Select Case Index
- Case 0 ' Hand
- Unload Me
- Case 2 ' Question Mark
- '*************************************************************
- ' Bring up the splash form again, because the first OLE
- ' Automation call will require Excel to be started. After
- ' it is started, any subsequent calls will be peformed
- ' as fast as they would be in a native Excel macro.
- '*************************************************************
- frmSplash.lblMessage = _
- "Gathering OLE Automation information from Excel...Please Wait!"
- frmSplash.Show
- frmSplash.Refresh
- '*************************************************************
- ' Load the info dialog, and start printing to it.
- '*************************************************************
- Load frmInfo
- '*************************************************************
- ' NOTE: Using the OLE Container's Object property, you can
- ' execute OLE Automation statements on the object in
- ' the control.
- '*************************************************************
- ' Using 2 .Parent properties, allows you to access Excel's
- ' Application object.
- '*************************************************************
- PrintMessage "Application Name:", _
- ActiveForm.Excel(0).Object.Parent.Parent.Name & " " & _
- ActiveForm.Excel(0).Object.Parent.Parent.Version
-
- PrintMessage "Operating System:", _
- ActiveForm.Excel(0).Object.Parent.Parent.OperatingSystem
-
- PrintMessage "Organization Name:", _
- ActiveForm.Excel(0).Object.Parent.Parent.OrganizationName
- '*************************************************************
- ' By default, the Object property points to a Worksheet.
- '*************************************************************
- PrintMessage "Range(""A2""):", _
- ActiveForm.Excel(0).Object.Range("A2")
- '*************************************************************
- ' Using 1 call to Parent, allows you to access Excel's
- ' Workbook object.
- '*************************************************************
- PrintMessage "Read Only:", _
- ActiveForm.Excel(0).Object.Parent.ReadOnly
-
- PrintMessage "Saved:", _
- ActiveForm.Excel(0).Object.Parent.Saved
-
- PrintMessage "Sheet Name:", _
- ActiveForm.Excel(0).Object.Name
-
- PrintMessage "Workbook Author:", _
- ActiveForm.Excel(0).Object.Parent.Author
-
- PrintMessage "Workbook Name:", _
- ActiveForm.Excel(0).Object.Parent.Name
- '*************************************************************
- ' Make sure all activity is complete, before unloading the
- ' the splash.
- '*************************************************************
- DoEvents
- Unload frmSplash
- '*************************************************************
- ' Display the information to the user.
- '*************************************************************
- frmInfo.Show 1
- End Select
- End Sub
- '*********************************************************************
- ' Print the formatted string to frmInfo.
- '*********************************************************************
- Private Sub PrintMessage(Item As String, Result As Variant)
- Dim LeftStr As String * 20, RightStr As String * 30
- LeftStr = Item
- RightStr = Result
- frmInfo.Print LeftStr & RightStr
- End Sub
- '*********************************************************************
- ' Prepares the application for use.
- '*********************************************************************
- Private Sub MDIForm_Load()
- Dim XLPath$
- '*****************************************************************
- ' Always use the system defined backcolor.
- '*****************************************************************
- BackColor = vb3DFace
- StatusBar.BackColor = vb3DFace
- Toolbar.BackColor = vb3DFace
- '*****************************************************************
- ' If necessary, start Excel to prevent annoying message boxes.
- '*****************************************************************
- XLPath = GetINI("Microsoft Excel", "cbtlocation", _
- "c:\excel\excelcbt", "excel5.ini")
- XLPath = Left(XLPath, Len(XLPath) - 8) & "excel.exe"
- StartedExcel = StartServer("XLMAIN", XLPath)
- WindowState = 2 'Maximized
- frmExcel.Show
- Arrange vbTileHorizontal
- End Sub
- '*********************************************************************
- ' Updates the status bar with the default text.
- '*********************************************************************
- Private Sub MDIForm_MouseMove(Button As Integer, Shift As Integer, _
- X As Single, Y As Single)
- UpdateStatus lblStatus
- End Sub
- '*********************************************************************
- ' If you had to start Excel, then close it. Otherwise, leave it alone.
- '*********************************************************************
- Private Sub MDIForm_Unload(Cancel As Integer)
- If StartedExcel <> False Then
- CloseApp StartedExcel
- End If
- End Sub
- '*********************************************************************
- ' Terminates the application.
- '*********************************************************************
- Private Sub mnuFileItems_Click(Index As Integer)
- Unload Me
- End Sub
- '*********************************************************************
- ' Updates the status bar with the default text.
- '*********************************************************************
- Private Sub StatusBar_MouseMove(Button As Integer, Shift As Integer, _
- X As Single, Y As Single)
- UpdateStatus lblStatus
- End Sub
- '*********************************************************************
- ' Adds a 3D appearance to the status bar.
- '*********************************************************************
- Private Sub StatusBar_Paint()
- HighlightBar StatusBar
- Highlight lblStatus
- End Sub
- '*********************************************************************
- ' Updates the status bar with the default text.
- '*********************************************************************
- Private Sub Toolbar_MouseMove(Button As Integer, Shift As Integer, _
- X As Single, Y As Single)
- UpdateStatus lblStatus
- End Sub
- '*********************************************************************
- ' Adds a 3D appearance to the toolbar.
- '*********************************************************************
- Private Sub Toolbar_Paint()
- HighlightBar Toolbar
- End Sub
- '*********************************************************************
- ' Adds a 3D effect to a picture box.
- '*********************************************************************
- Private Sub HighlightBar(Bar As PictureBox)
- Bar.Line (0, 5)-(Bar.ScaleWidth, 5), vb3DHighlight
- Bar.Line (0, Bar.ScaleHeight - 15)-(Bar.ScaleWidth, _
- Bar.ScaleHeight - 15), vb3DShadow
- End Sub
- '*********************************************************************
- ' Adds a 3D border around a control.
- '*********************************************************************
- Private Sub Highlight(Object As Control)
- Const HORIZONTAL_OFFSET = 50
- Const VERTICAL_OFFSET = 70
- '*****************************************************************
- ' Top
- '*****************************************************************
- StatusBar.Line (Object.Left - HORIZONTAL_OFFSET, _
- Object.Top - HORIZONTAL_OFFSET)- _
- (Object.Width, _
- Object.Top - HORIZONTAL_OFFSET), _
- vb3DShadow
- '*****************************************************************
- ' Left
- '*****************************************************************
- StatusBar.Line (Object.Left - HORIZONTAL_OFFSET, _
- Object.Top - HORIZONTAL_OFFSET)- _
- (Object.Left - HORIZONTAL_OFFSET, _
- Object.Height + VERTICAL_OFFSET), _
- vb3DShadow
- '*****************************************************************
- ' Bottom
- '*****************************************************************
- StatusBar.Line (Object.Left - HORIZONTAL_OFFSET, _
- Object.Height + VERTICAL_OFFSET)- _
- (Object.Width, _
- Object.Height + VERTICAL_OFFSET), _
- vb3DHighlight
- '*****************************************************************
- ' Right
- '*****************************************************************
- StatusBar.Line (Object.Width, _
- Object.Top - HORIZONTAL_OFFSET)- _
- (Object.Width, _
- Object.Height + VERTICAL_OFFSET + 15), _
- vb3DHighlight
- End Sub
-