Link to home
Avatar of Peter Chan
Peter ChanFlag for Hong Kong

asked on

Problem to line

Hi,
I've got error
User generated image
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?
Avatar of Peter Kiprop
Peter Kiprop

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

Avatar of Peter Chan

ASKER

I tried with your codes and still encountered the same problem.

The relevant path is correct.
ASKER CERTIFIED SOLUTION
Avatar of Qlemo
Qlemo
Flag of Germany image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
I cannot show

Debug.Print File0

in Watch window. What to adjust?
In Watch window you only type File0, no command.
I want to see value of File0 but I get nothing.
To use Watch window, you need to set a breakpoint e.g. at the debug.print line.
Debug.Print should still show the value of File0, even if there is no break point, right?
Yes. BUt you need to have the Output window (or whatever it is called) opened to see.
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.
SOLUTION
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
I get
User generated image
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.
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.
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
User generated image
I can't see the real path in the screenshot.
Here is the relevant path
User generated image
Problem is that Application.ActiveWorkbook.Path is not showing correct path as expected.
Any help?
Do you have more than one workbook open, so that the active one is not the one that you are expecting?
In your last snippet, what is the type and value of Window0?

Is it a file name or an index number?
What's the solution?