×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

SetParent disables part of child functionality

SetParent disables part of child functionality

SetParent disables part of child functionality

(OP)
Hello,

I am trying to load a selected Excel workbook into an Access subform that is on an Access form. I want to be able to select information in the spreadsheet then send it back to my main form and use it for processing. I have it working so that the Excel application and workbook both load into the subform but I am unable to click on a cell and edit the information, select a row or column or use the scroll bars. Ideally, I would only like to display only the workbook portion of the Excel window so I can select rows, columns and cells.

If anyone could give me some advice I would really appreciate it. Here is the code I'm using.


CODE

Option Compare Database
Option Explicit

Private Declare Function SetParent Lib "user32" _
   (ByVal hWndChild As Long, _
    ByVal hWndNewParent As Long) As Long
Private Declare Function FindWindowEx Lib "user32" _
    Alias "FindWindowExA" _
    (ByVal hWnd1 As Long, _
    ByVal hWnd2 As Long, _
    ByVal lpsz1 As String, _
    ByVal lpsz2 As String) _
    As Long

Sub WorkOnAWorkbook()
Dim appExcel As Excel.Application
Dim wb As Excel.Workbook
Dim ws As Excel.Worksheet
Dim bool As Boolean
Dim strFile As String
Dim strWbName As String
Dim wbk As Long

strFile = Get_ExcelLocation("")

On Error Resume Next
Set appExcel = GetObject(, "Excel.Application")
If Err Then
    bool = True  'Excel was not running
    Set appExcel = New Excel.Application
End If
On Error GoTo Err_Handler

Set wb = appExcel.Workbooks.Open(FileName:=strFile)
strWbName = Mid(strFile, InStrRev(strFile, "\") + 1, (Len(strFile) - 3) - (InStrRev(strFile, "\") + 1))

SetParent appExcel.hWnd, sfrXL.Form.hWnd

Set ws = wb.Sheets(1)
ws.Select
ws.Activate
appExcel.Visible = True
Exit Sub

Err_Handler:
   MsgBox strFile & " caused a problem. " & Err.Description, vbCritical, _
           "Error: " & Err.Number
   If bool Then
       appExcel.Quit
   End If

End Sub


Thanks,
Wendy

RE: SetParent disables part of child functionality

(OP)
IPlease, is anyone able to give me a hand?

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close