Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Opening file saved as current date


I have the following code that I want to open a text file that is saved
as the current date. It works but opens the text file in a new excel
spreadsheet. Is there any way to open the file in my "tester.xls"
(which is where I have this macro)?


Code:
--------------------


Sub True()

Dim SourceBook As Workbook

ChDir ("C:\Program Files\helper")
Set SourceBook = Workbooks.Open(Filename:=Format(Date, "mm_dd_yy.txt"))

End Sub


--------------------


--
Yepp12
------------------------------------------------------------------------
Yepp12's Profile: http://www.excelforum.com/member.php...o&userid=28740
View this thread: http://www.excelforum.com/showthread...hreadid=492855

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Opening file saved as current date

Sub True()

Dim SourceBook As Workbook
Dim sh as Worksheet
With Activeworkbook
set sh = .Worksheets.Add(After:=.Worksheets(Worksheets.coun t))
End with
sh.Name = "Data1"
ChDir ("C:\Program Files\helper")
Set SourceBook = Workbooks.Open(Filename:=Format(Date, "mm_dd_yy.txt"))
SourceBook.Worksheets(1).UserRange.copy _
Destination:=sh.Range("A1")
sourceBook.Close SaveChanges:=False
End Sub

--
Regards,
Tom Ogilvy


"Yepp12" wrote in
message ...

I have the following code that I want to open a text file that is saved
as the current date. It works but opens the text file in a new excel
spreadsheet. Is there any way to open the file in my "tester.xls"
(which is where I have this macro)?


Code:
--------------------


Sub True()

Dim SourceBook As Workbook

ChDir ("C:\Program Files\helper")
Set SourceBook = Workbooks.Open(Filename:=Format(Date, "mm_dd_yy.txt"))

End Sub


--------------------


--
Yepp12
------------------------------------------------------------------------
Yepp12's Profile:

http://www.excelforum.com/member.php...o&userid=28740
View this thread: http://www.excelforum.com/showthread...hreadid=492855



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Opening file saved as current date

First, I wouldn't use True as a subroutine name. It looks too much like True
(as in the boolean value True.)

Sub myTrue()
Dim SourceBook As Workbook
Set SourceBook = Workbooks.Open _
(Filename:="C:\Program Files\helper\" & Format(Date, "mm_dd_yy.txt"))

activesheet.copy _
after:=thisworkbook.sheets(thisworkbook.sheets.cou nt)

sourcebook.close savechanges:=false

End Sub

Yepp12 wrote:

I have the following code that I want to open a text file that is saved
as the current date. It works but opens the text file in a new excel
spreadsheet. Is there any way to open the file in my "tester.xls"
(which is where I have this macro)?

Code:
--------------------


Sub True()

Dim SourceBook As Workbook

ChDir ("C:\Program Files\helper")
Set SourceBook = Workbooks.Open(Filename:=Format(Date, "mm_dd_yy.txt"))

End Sub


--------------------

--
Yepp12
------------------------------------------------------------------------
Yepp12's Profile: http://www.excelforum.com/member.php...o&userid=28740
View this thread: http://www.excelforum.com/showthread...hreadid=492855


--

Dave Peterson
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Opening file saved as current date


Thanks guys for your help.


--
Yepp12
------------------------------------------------------------------------
Yepp12's Profile: http://www.excelforum.com/member.php...o&userid=28740
View this thread: http://www.excelforum.com/showthread...hreadid=492855

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
Edits not saved when re-opening file SmartCookie Excel Worksheet Functions 1 January 2nd 09 07:16 PM
how to find where is the current file saved Holly Excel Discussion (Misc queries) 3 December 5th 07 12:44 PM
Make date change in excel to current date when opening daily? jamie Excel Discussion (Misc queries) 3 March 1st 06 03:37 PM
SELECTING CURRENT DATE AT OPENING R VAN DEURSEN Excel Worksheet Functions 5 March 7th 05 07:38 AM
Opening a saved file elien99 Excel Programming 4 December 14th 03 12:46 AM


All times are GMT +1. The time now is 12:38 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"