Problem to line

Hi,
I've got error
21e.png
due to last line below
    File0 = Replace(Replace(ActiveWorkbook.Path & "\..\Index\" & File1 & ".txt", "/", "\"), "http:", "")
    Debug.Print File0
    Open File0 For Output As #1

Open in new window


and could not capture value of File0 in Watch window. Why?
LVL 11
HuaMin ChenSystem AnalystAsked:
Who is Participating?
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Have you checked on what ActiveWorkbook.Path returns? The current workbook needs to have been saved at least once after being created.
The path dumped in the command window by Debug.Print looks correct?
0
 
Peter KipropCommented:
try the code below

    File0 = Replace(Replace(ActiveWorkbook.Path & "\Index\" & File1 & ".txt", "/", "\"), "http:", "")
    Debug.Print File0
    Open File0 For Output As #1

Open in new window

0
 
HuaMin ChenSystem AnalystAuthor Commented:
I tried with your codes and still encountered the same problem.

The relevant path is correct.
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
HuaMin ChenSystem AnalystAuthor Commented:
I cannot show

Debug.Print File0

in Watch window. What to adjust?
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
In Watch window you only type File0, no command.
0
 
HuaMin ChenSystem AnalystAuthor Commented:
I want to see value of File0 but I get nothing.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
To use Watch window, you need to set a breakpoint e.g. at the debug.print line.
0
 
HuaMin ChenSystem AnalystAuthor Commented:
Debug.Print should still show the value of File0, even if there is no break point, right?
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
Yes. BUt you need to have the Output window (or whatever it is called) opened to see.
0
 
HuaMin ChenSystem AnalystAuthor Commented:
I want to refer to current path of Excel file (Within Sharepoint). It seems ActiveWorkbook.Path is not revealing the correct path of current Excel file.
0
 
GrahamSkanRetiredCommented:
It is formally known as the 'Immediate Window', but some call it the 'debug window'. It can be opened with Ctrl+G.
0
 
HuaMin ChenSystem AnalystAuthor Commented:
I get
21j.png
due to last line below

    File0 = Replace(Replace(Application.ActiveWorkbook.Path & "\..\Index\" & File1 & ".txt", "/", "\"), "http:", "")

    'File0 = ActiveWorkbook.Path & "\..\Index\" & File1 & ".txt"
    Debug.Print Application.ActiveWorkbook.Path
    Debug.Print File0
    Open File0 For Output As #1

Open in new window


it seems Application.ActiveWorkbook.Path is not revealing the correct path of current Excel file being opened.
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
We might be able to help if you provide example output of the debug print above, as I don't have a clue how SharePoint provides its files.
0
 
HuaMin ChenSystem AnalystAuthor Commented:
Here are Debug values I've got

\\hfactx.corp.zim.com\ctx$\UPM.FR\HKGDesktop
\\hfactx.corp.zim.com\ctx$\UPM.FR\HKGDesktop\..\Index\JAPAN.txt

but actually current Excel file is residing in the following path
21m.png
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
I can't see the real path in the screenshot.
0
 
HuaMin ChenSystem AnalystAuthor Commented:
Here is the relevant path
21n.png
Problem is that Application.ActiveWorkbook.Path is not showing correct path as expected.
0
 
HuaMin ChenSystem AnalystAuthor Commented:
Any help?
0
 
GrahamSkanRetiredCommented:
Do you have more than one workbook open, so that the active one is not the one that you are expecting?
0
 
GrahamSkanRetiredCommented:
In your last snippet, what is the type and value of Window0?

Is it a file name or an index number?
0
 
QlemoBatchelor, Developer and EE Topic AdvisorCommented:
What's the solution?
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.