By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,376 Members | 3,024 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,376 IT Pros & Developers. It's quick & easy.

CurDir returns current directory one folder short

P: 2
While using CurDir to get the current path where my open workbook is located, I get a result that's short of the current folder.e.g. the path to the file is C:\FolderLv1\FolderLv2\FolderLv3\Myfile.xls

And CurDir returns: C:\FolderLv1\FolderLv2

This creates a problem when trying to open the next xls file in the same folder.

Can anyone help?
Here is the code:

Private Sub ConsolidationButton_Click()
Dim strYear As String
Dim strMonth As String
Dim stCrurrentSite As String
Dim strFilePath As String
Dim strFileName As String



Dim consolidate_app As Object

' Create the Excel application.
Set consolidate_app = CreateObject("Excel.Application")

strYear = InputBox("Enter the Year in format YYYY:", "Monthly Consolidation")
strMonth = InputBox("Enter the Month in format MM:", "Monthly Consolidation")



strFilePath = CurDir()
MsgBox (strFilePath)
strFileName = "HR Input Sheet LNO.xls"
MsgBox (strFilePath & "\" & strFileName)

consolidate_app.Workbooks.Open (strFilePath & "\" & strFileName)
consolidate_app.Workbooks(strFileName).Activate
ActiveWorkbook.NewWindow


End Sub
Jul 9 '08 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.