Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Setting a dynamic path for VBA

  Asked By: Asksuresh    Date: Oct 19    Category: MS Office    Views: 1201
  

I have a problem regarding following issue, please kindly help me, thanks


Daily I have to update some files of Xls & what I do is that I make new folder
with the Today’s date , i.e last time I made 17-may-07 , on next day I’ll copy
the same files into new folder 18-may-07 …

I want make a macro that suppose dailyreport.xls file open automatically with
the master file spouse shares.xls files

I try to do



Private Sub Workbook_Open()
Workbooks.Open "[dailyreport.xls]"
End Sub


But it gives me debug error as its unable to recognize the folder name, but
thing is Both files are in same folder!

Share: 

 

2 Answers Found

 
Answer #1    Answered By: Dang Tran     Answered On: Oct 19

Try it without the brackets.

If that does not work you may need to specify the path.

 
Answer #2    Answered By: Jamie Roberts     Answered On: Oct 19

i got this code & its working for me,



Private Sub Matched_Password()
Dim posn As Integer, i As Integer
Dim flName As String
Dim fPath As String ' path  of file

flName = ThisWorkbook.FullName

posn = 0

For i = 1 To Len(flName)
If (Mid(flName, i, 1) = "\") Then posn = i
Next i

fPath = Left(flName, posn - 1)

Workbooks.Open fPath & "\dailyreport.xls"
Workbooks.Open fPath & "\sharesfile.xls"
Call SSGC
End Sub

David Grugeon <yahoo@...> wrote:
Hi Sajjad

Try it without the brackets.

If that does not work you may need to specify the path.

 
Didn't find what you were looking for? Find more on Setting a dynamic path for VBA Or get search suggestion and latest updates.




Tagged: