Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 846
Default Opening files with variable names

I'm looking for code to open an excel workbook with a variable name. The file
name should be fairly constant except there will be a revision level on the
end of the file name. For example, C:\Excelfile rev.01.

Is there some code to open a filename containing a phrase?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Opening files with variable names

Open any module and paste the codes they are read through the comments

Function WorkbookOpen(Mydir As String, WorkBookName As String, VC As String)

' by Ritwik Shukla
' MyDir is path of directory
' My workbbok name is standard name of the excel workbooks
' VC is version control



fullpath = Mydir & "\" & WorkBookName & VC & ".xls" ' Your full path

Workbooks.Open fullpath


End Function

Testing This function :

Lest say you have 4 file stored in C:\Manyfile folder and names are
test1.xls, test2.xls and so on


Sub openbookTest()

Dim N As Integer ' VC as Integer
Dim I As String ' Vc as String

For N = 1 To 4 ' You can set this value vy counting files in folder
' visit http://www.ozgrid.com/forum/showthread.php?t=51500

I = N

Call WorkbookOpen("C:\Manyfile", "Test", I) ' Calling function

Next N

End Sub

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
Macro for opening files that changes names [email protected] Excel Discussion (Misc queries) 1 May 12th 07 06:15 PM
Rename files with variable names Robert_L_Ross Excel Programming 1 June 20th 06 06:52 PM
Opening Variable File Names simoncohen[_7_] Excel Programming 1 November 16th 04 01:49 PM
excel VBA problem - setting workbook as variable & opening/re-opening safe Excel Programming 1 August 20th 04 12:22 AM
Opening files from a variable (todays' date) folder name Hari[_3_] Excel Programming 2 June 10th 04 04:03 PM


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