Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default button to open a file

I don't have any programming experience, but I was wondering if ther
was a way to make a button in Excel that you could click and have i
open a file and copy the file into your already open worksheet.

At first I thought it may be as simple as creating a macro, but now
don't think so.

What I would like the button to do is:
1. Open a box that asks you to select the file you want to open.
2. Open the file (a .txt file) and select Delimited with Tabs an
Spaces as delimiters.
3. Copy the contents of the file an place them into the worksheet yo
already have open.

I would love it if the only user intervention was selecting the prope
file to open, and the program did the rest.

Is this that difficult to accomplish? I guess I will go read up o
programming in Excel

--
Message posted from http://www.ExcelForum.com

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default button to open a file

Sorry about the multiple threads, my internet has been acting wierd

--
Message posted from http://www.ExcelForum.com

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default button to open a file

If you're using xl2k or higher, try recording a macro when you do:
Data|Import external data (may be a different name in different versions).

If you're using xl97 (or higher even), you could use something like:
Option Explicit
Sub testme()

Dim myFileName As Variant
Dim DestCell As Range

myFileName = Application.GetOpenFilename("Text files, *.txt")

If myFileName = False Then
Exit Sub 'user hit cancel
End If

With ActiveSheet
Set DestCell = .Cells(.Rows.Count, "A").End(xlUp).Offset(1, 0)
End With

Workbooks.OpenText Filename:=myFileName, _
Origin:=437, StartRow:=1, DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=True, Tab:=True, Semicolon:=False, Comma:=False, _
Space:=True

ActiveSheet.UsedRange.Copy _
Destination:=DestCell

ActiveSheet.Parent.Close savechanges:=False


End Sub

"kolbydayne <" wrote:

I don't have any programming experience, but I was wondering if there
was a way to make a button in Excel that you could click and have it
open a file and copy the file into your already open worksheet.

At first I thought it may be as simple as creating a macro, but now I
don't think so.

What I would like the button to do is:
1. Open a box that asks you to select the file you want to open.
2. Open the file (a .txt file) and select Delimited with Tabs and
Spaces as delimiters.
3. Copy the contents of the file an place them into the worksheet you
already have open.

I would love it if the only user intervention was selecting the proper
file to open, and the program did the rest.

Is this that difficult to accomplish? I guess I will go read up on
programming in Excel!

---
Message posted from http://www.ExcelForum.com/


--

Dave Peterson

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
need macro from button to open selectable file dillon26 Excel Worksheet Functions 1 February 8th 09 09:55 AM
how to get a button added to a speardsheet to open another file? RS Excel Discussion (Misc queries) 1 April 10th 08 04:39 PM
Favourites button - File Open dialog box Aussie CPA Excel Discussion (Misc queries) 1 August 11th 05 02:42 PM
Create button to open a file kolbydayne Excel Programming 0 August 5th 04 04:55 PM
VBA - on a button event, open another closed file, post changes, close file Fio Excel Programming 0 March 1st 04 01:08 PM


All times are GMT +1. The time now is 11:48 PM.

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

About Us

"It's about Microsoft Excel"