|
-
Jul 26th, 2001, 04:20 AM
#1
Thread Starter
New Member
Activating Excel sheet in OLE container
Hello
I have created an OLE container on a form that links to a range in an Excel worksheet. Running the project, I see the correct range in the container, but I would like to be able to edit the contents with the Excel window remaining inside the container, as happens when you double-click an Excel graph pasted into Word, for example. At the moment, when I double click (or any other way you choose to open the container for object editing during run time), a seperate Excel window opens with the focus not especially on the intended range of cells.
Private Sub LoadExcelRange()
If OLE_ExcelRange.SourceDoc = "" Then
OLE_ExcelRange.CreateLink "ExcelWorkbookPath.xls!ExcelRange"
End If
OLE_ExcelRange.AutoActivate = 2 'or 1 depending on opening mode desired
End Sub
I thought of tricking the Excel window into appearing in the right place by adding a Click procedure along the lines of:
Private Sub OLE_ExcelRange_Click()
Dim xlExcelFile As Excel.Workbook
Set xlExcelFile = OLE_ExcelRange.object
With xlExcelFile
.Windows(1).Activate
.Application.Visible = True
With .Application.ActiveWindow
.Left = OLE_ExcelRange.Left
.Top = OLE_ExcelRange.Top
.Width = OLE_ExcelRange.Width
.Height = OLE_ExcelRange.Height
End With
End With
End Sub
but that doesn't work and anyway there should be an easier and more elegant way of solving the problem.
Thanks for any input
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|