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 12
HuaMin ChenProblem resolverAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

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 ChenProblem resolverAuthor Commented:
I tried with your codes and still encountered the same problem.

The relevant path is correct.
0
Qlemo"Batchelor", 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

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

HuaMin ChenProblem resolverAuthor Commented:
I cannot show

Debug.Print File0

in Watch window. What to adjust?
0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
In Watch window you only type File0, no command.
0
HuaMin ChenProblem resolverAuthor Commented:
I want to see value of File0 but I get nothing.
0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
To use Watch window, you need to set a breakpoint e.g. at the debug.print line.
0
HuaMin ChenProblem resolverAuthor Commented:
Debug.Print should still show the value of File0, even if there is no break point, right?
0
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
Yes. BUt you need to have the Output window (or whatever it is called) opened to see.
0
HuaMin ChenProblem resolverAuthor 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 ChenProblem resolverAuthor 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
Qlemo"Batchelor", 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 ChenProblem resolverAuthor 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
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
I can't see the real path in the screenshot.
0
HuaMin ChenProblem resolverAuthor Commented:
Here is the relevant path
21n.png
Problem is that Application.ActiveWorkbook.Path is not showing correct path as expected.
0
HuaMin ChenProblem resolverAuthor 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
Qlemo"Batchelor", Developer and EE Topic AdvisorCommented:
What's the solution?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Miscellaneous

From novice to tech pro — start learning today.