Browse and attach file in a UserForm
Generally, you don't embed on excel file inside another. Generally, you
open both files and copy the information you need from one to the other.
You could link them with a formula. And easy way is to copy the data and
then do a past special and select the link option. this puts in a linking
formula and can be done with code.
Private Sub CommandButton2_Click()
Dim TheFile As Variant
Dim bk as workbook
TheFile = Application.GetOpenFilename( _
"Excel files (*.xls), *.xls", , _
"Pick a file")
If TheFile < False Then
set bk =Workbooks.Open( TheFile)
Else
exit sub
End If
bk.worksheets(1).Cells(1,1).currentRegion.copy _
Destination:=me.cells(rows.count,1).end(xlup).Offs et(1,0)
End Sub
now bk is object.
--
Regards,
Tom Ogilvy
--
Regards,
Tom Ogilvy
"Jeroen Kluytmans" wrote in message
om...
Hello,
I would like to make an option in a userform to browse a file and add
it to the excel sheet. I don't have a clue how to make this. Can
anybody help me with a start?
So far I can open a file, but I can not manage to just make a linkt to
the object, or load the file as object in the excel file. It would be
best if the link to the file or the object can be copied in a cell in
the worksheet.
Private Sub CommandButton2_Click()
Dim TheFile As Variant
TheFile = Application.GetOpenFilename("Excel files (*.xls), *.xls", ,
_
"Pick a file")
If TheFile < False Then
Workbooks.Open TheFile
End If
End Sub
Any help welcome
Kind regards,
Jeroen Kluytmans
|