lynnnow
06-27-2012, 11:25 PM
Hi All,
I've been using ActiveWorkbook.Path quite successfully for all this while, but now when I am opening my workbook and need to read a text file from the activeworkbook's folder, the folder path is being displayed as the temp folder, and that stops the macro from running. I've added an On Error Resume Next line, but it breaks at the file Open line:
Sub ToolBarAuditor()
Dim popUpBar As CommandBar
Dim newButton As CommandBarControl
Dim strAudis As String
'Dim blnintext, strdatarng
On Error Resume Next
CommandBars("AuditBar").Delete
On Error GoTo 0
Dim strAudiT As String
strAudiT = ActiveWorkbook.Path & "\AudiT.txt" '--- PATH DISPLAYED IS THE TEMP FOLDER
Open strAudiT For Input As #1 '---THIS IS WHERE IT BREAKS SINCE FILE IS NOT FOUND
Line Input #1, strDataRng
Close #1
I have to use activeworkbook, since I've got other workbooks also open and only this workbook uses this bit of code.
Also, I'm using Office 2003 on Win XP with the 2007 compatibility pact installed. My wbk is in xlsm format.
I've been using ActiveWorkbook.Path quite successfully for all this while, but now when I am opening my workbook and need to read a text file from the activeworkbook's folder, the folder path is being displayed as the temp folder, and that stops the macro from running. I've added an On Error Resume Next line, but it breaks at the file Open line:
Sub ToolBarAuditor()
Dim popUpBar As CommandBar
Dim newButton As CommandBarControl
Dim strAudis As String
'Dim blnintext, strdatarng
On Error Resume Next
CommandBars("AuditBar").Delete
On Error GoTo 0
Dim strAudiT As String
strAudiT = ActiveWorkbook.Path & "\AudiT.txt" '--- PATH DISPLAYED IS THE TEMP FOLDER
Open strAudiT For Input As #1 '---THIS IS WHERE IT BREAKS SINCE FILE IS NOT FOUND
Line Input #1, strDataRng
Close #1
I have to use activeworkbook, since I've got other workbooks also open and only this workbook uses this bit of code.
Also, I'm using Office 2003 on Win XP with the 2007 compatibility pact installed. My wbk is in xlsm format.