mattdrinks
Technical User
Working in Access 2000 and Excel 2000
I have a button on an access form which runs the following code:
This all works fine but I would like to show the instance of excel in the lower part of the form, I can set the excel window to the right size and can keep it in proportion using code in the resize event of the form.
But I can not find a property of the form that tells me where the form is postioned on the screen allowing me to postion the instance of excel in the correct place whenever the form is moved.
The application object of excel has a top property it contains: The distance from the top edge of the screen to the top edge of the main Microsoft Excel window.
I can not find a similar property for an access form allowing me to synchronize them.
Can anybody point me in the right direction, any help greatly appricaited.
Matt
I have a button on an access form which runs the following code:
Code:
Private Sub cmdGetData_Click()
Dim xlData As Excel.Application
Dim strFileName As String
Dim bar As Office.CommandBar
Dim intI As Integer
Dim lngFormWidth As Long
Dim lngFormHeight As Long
Dim booBarEnabled() As Boolean
Dim booDisplayFormulaBar As Boolean
Dim intTotalCommandBars As Integer
'open an instance of excel
Set xlData = CreateObject("Excel.Application")
'count the visible commandbars in excel
intTotalCommandBars = 0
For Each bar In xlData.CommandBars
intTotalCommandBars = intTotalCommandBars + 1
Next
'redeclare the array at the correct size
ReDim booBarEnabled(intTotalCommandBars) As Boolean
'save current status then disable all command bars
intI = 0
For Each bar In xlData.CommandBars
booBarEnabled(intI) = bar.Enabled
bar.Enabled = False
intI = intI + 1
Next
'save current excel settings
booDisplayFormulaBar = xlData.DisplayFormulaBar
'set up excel with options we reqiuire
xlData.DisplayFormulaBar = False
'let user select a file
strFileName = xlData.GetOpenFilename("CSV, *.csv, Excel, *.xls")
xlData.Workbooks.Open (strFileName)
'set the excel window size
xlData.WindowState = xlNormal
lngFormHeight = Me.WindowHeight / 20
lngFormWidth = Me.WindowWidth / 20
xlData.Width = lngFormWidth
xlData.Height = lngFormHeight / 2
'make excel visible
xlData.Visible = True
MsgBox (strFileName)
'set excel back to original settings
intI = 0
For Each bar In xlData.CommandBars
bar.Enabled = booBarEnabled(intI)
intI = intI + 1
Next
xlData.DisplayFormulaBar = booDisplayFormulaBar
xlData.Quit
Set xlData = Nothing
End Sub
This all works fine but I would like to show the instance of excel in the lower part of the form, I can set the excel window to the right size and can keep it in proportion using code in the resize event of the form.
But I can not find a property of the form that tells me where the form is postioned on the screen allowing me to postion the instance of excel in the correct place whenever the form is moved.
The application object of excel has a top property it contains: The distance from the top edge of the screen to the top edge of the main Microsoft Excel window.
I can not find a similar property for an access form allowing me to synchronize them.
Can anybody point me in the right direction, any help greatly appricaited.
Matt