Click to See Complete Forum and Search --> : Embedding Excel Sheet in VB


Nick W
January 15th, 1999, 04:24 PM
Hi,

I am currently trying to embed an Excel sheet in a VB app. No problems there. I essentially place an OLE container on the form and set the class to an excel sheet. The trouble comes when I resize the form (MDIChild window). The container apparently resizes OK, but the Excel sheet does not!!! Any help would be great as this is driving me mad!!!


Many Thanks


Nick

Hugo
June 15th, 1999, 02:07 PM
Try the following...

Use this function to get scroll bar thickness..

Public Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
Public Const SM_CXVSCROLL = 2
Public Const SM_CYHSCROLL = 3
Public Const SM_CYVSCROLL = 20
Public Const SM_CXHSCROLL = 21


This is the code to resize...


private Sub Form_Resize()
If Not (frmViewGraphics.WindowState = vbMinimized) then

' Resize the Ole control accounting for scrollbar thickness
'
OLEView.Width = frmView.ScaleWidth - GetSystemMetrics(SM_CXVSCROLL) * Screen.TwipsPerPixelX
OLEView.Height = frmView.ScaleHeight - GetSystemMetrics(SM_CYHSCROLL) * Screen.TwipsPerPixelY
End If
End Sub