home *** CD-ROM | disk | FTP | other *** search
- VERSION 4.00
- Begin VB.Form Form1
- Caption = "OLE Object Viewer"
- ClientHeight = 4230
- ClientLeft = 2295
- ClientTop = 2280
- ClientWidth = 6720
- BeginProperty Font
- name = "MS Sans Serif"
- charset = 0
- weight = 400
- size = 8.25
- underline = 0 'False
- italic = 0 'False
- strikethrough = 0 'False
- EndProperty
- Height = 4920
- Left = 2235
- LinkTopic = "Form1"
- MDIChild = -1 'True
- ScaleHeight = 540
- ScaleWidth = 540
- Top = 1650
- Width = 6840
- Begin VB.TextBox txtObj
- Height = 4215
- Left = 0
- MultiLine = -1 'True
- ScrollBars = 3 'Both
- TabIndex = 1
- Text = "Text1"
- Top = 0
- Width = 6735
- End
- Begin VB.Image imgObj
- Height = 4215
- Left = 0
- Top = 0
- Width = 6735
- End
- Begin MSComDlg.CommonDialog cmnDlg
- Left = 1200
- Top = 3960
- _version = 65536
- _extentx = 847
- _extenty = 847
- _stockprops = 0
- dialogtitle = "View OLE File"
- filter = "*.xls; *.doc; *.vsd"
- filterindex = 1
- End
- Begin VB.OLE oleObject
- AutoActivate = 3 'Automatic
- Class = "Word.Document.6"
- Height = 4215
- Left = 0
- SizeMode = 2 'AutoSize
- TabIndex = 0
- Top = 0
- Width = 6750
- End
- Begin VB.Menu mnuFile
- Caption = "&File"
- Begin VB.Menu mnuView
- Caption = "&View..."
- End
- Begin VB.Menu mnuitExit
- Caption = "E&xit"
- End
- End
- Attribute VB_Name = "Form1"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = False
- Option Explicit
- Private Sub mnuView_Click()
- ' New: Set up error handling.
- On Error Resume Next
- ' Show all filenames.
- cmnDlg.FileName = "*.*"
- ' Display the Open common dialog.
- cmnDlg.ShowOpen
- ' Make sure a filename was entered and that the file exists.
- If (cmnDlg.FileName <> "") And Len(Dir(cmnDlg.FileName)) Then
- ' Display the file in the OLE object.
- oleObject.CreateEmbed cmnDlg.FileName
- ' New: If the file was not an OLE object,
- ' load the file as a non-OLE object.
- If Err Then DisplayNonOLEObject (cmnDlg.FileName)
- ' New: Hide other objects
- imgObj.Visible = False
- txtObj.Visible = False
- oleObject.Visible = True
- End If
- End Sub
- Private Sub mnuitExit_Click()
- End
- End Sub
- ' Resize the form to fit the object.
- Private Sub oleObject_Resize(HeightNew As Single, WidthNew As Single)
- Me.Height = HeightNew
- Me.Width = WidthNew
- End Sub
- ' Handles displaying other types of files.
- Sub DisplayNonOLEObject(strFile As String)
- ' Check for errors.
- On Error Resume Next
- Dim strBuffer As String, iFile As Integer
- ' If the file is a graphic, display it in
- ' an Image control.
- imgObj.Picture = LoadPicture(strFile)
- ' If the file was a valid picture, then
- ' display the image control and hide others.
- If Err = 0 Then
- ' Hide other objects
- imgObj.Visible = True
- txtObj.Visible = False
- oleObject.Visible = False
- ' Reset form's Height and Width to match
- ' Image control.
- Me.Height = imgObj.Height
- Me.Width = imgObj.Width
- ' If the file wasn't a valid picture, then
- ' load the data into a text box and hide other
- ' controls.
- Else
- iFile = FreeFile
- Open strFile For Binary As iFile
- strBuffer = Space(LOF(iFile))
- Get iFile, 1, strBuffer
- Close iFile
- txtObj.Text = strBuffer
- ' Hide other objects
- imgObj.Visible = False
- txtObj.Visible = False
- oleObject.Visible = False
- ' Reset form's Height and Width to match
- ' Text Box control.
- Me.Height = txtObj.Height
- Me.Width = txtObj.Width
- End If
- End Sub
- Private Sub oleObject_Updated(Code As Integer)
- Me.Caption = oleObject.HostName
- End Sub
-