View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Ritwik Shukla[_2_] Ritwik Shukla[_2_] is offline
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