Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Browse and attach file in a UserForm

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Browse and attach file in a UserForm

Tom,

Sorry, but I did not specifically mean a xls file. The format of the
file micht be any format. The example was for the xls file, but I
would like to link to any object. I recorded a Macro when linking the
object to the sheet, but this did not give me a clue how to program
this. It would be best if I can really upload a document in the excel
file so that if the file is opened at another computer the file is
embedded in the worksheet. Is this possible?

Regards,
Jeroen Kluytmans

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.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Browse File for Mac John Vickers Excel Discussion (Misc queries) 1 February 17th 06 06:23 PM
can't browse file k_anucha Excel Discussion (Misc queries) 1 September 29th 05 01:51 AM
excel vba browse file jazzy Excel Programming 3 August 5th 04 09:30 PM
File Browse Box JONNIE Excel Programming 2 February 5th 04 05:22 PM
Adding browse button to userform Brad[_11_] Excel Programming 1 December 1st 03 04:04 PM


All times are GMT +1. The time now is 09:57 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"