none
Problem to Application.ActiveWorkbook.Path RRS feed

  • Question

  • Hi,

    I did get

    due to Open line below

        File0 = Application.ActiveWorkbook.Path & "\..\Index\" & File1 & ".txt"
    
        'File0 = ActiveWorkbook.Path & "\..\Index\" & File1 & ".txt"
        Debug.Print Application.ActiveWorkbook.Path
        Debug.Print File0
       
        Open File0 For Output As #1
    
    I do not know why now Application.ActiveWorkbook.Path is showing one totally different path (not the exact path on which the Excel WorkBook is residing)


    Many Thanks & Best Regards, Hua Min

    Tuesday, March 6, 2018 8:45 AM

Answers

  • How did you configure SharePoint under Citrix?

    I make a test with SharePoint online, it output the expected path by "ActiveWorkbook.Path".


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Jackson_1990 Tuesday, March 13, 2018 9:29 AM
    Tuesday, March 13, 2018 6:40 AM

All replies

  • Hello HuaMin Chen,

    Please print active workbook's name to check if current workbook is the workbook you want.

    Besides, I would suggest you share whole code in the macro in case that you did any action we do not know.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 6, 2018 9:27 AM
  • Hi,

    I can see ActiveWorkbook.Name is showing name of current WorkBook correctly. Really it is not revealing the correct server name.


    Many Thanks & Best Regards, Hua Min


    Tuesday, March 6, 2018 9:47 AM
  • Hi,

    Any advice?


    Many Thanks & Best Regards, Hua Min

    Wednesday, March 7, 2018 4:43 AM
  • Hello HuaMin Chen,

    >>Really it is not revealing the correct server name

    Do you store the workbook in a server path? If you store the file in a server path and then mapped it as a local path, the code will return a mapped local path. For instance, I put a workbook in "\\OFFICE2016\Share" and then mapped "\\OFFICE2016\Share" as "Z:". If I run then workbook from "Z:", printed workbook path will be "Z:" rather than "\\OFFICE2016\Share".

    I think that's why you think it does not return the server, right?

    If so, please try to use below code to return its server path.

    Note: Add reference to "Microsoft Scripting Runtime".

        mappedDrivePath = ActiveWorkbook.Path
        Dim objFso As FileSystemObject
        Set objFso = CreateObject("Scripting.FileSystemObject")
    
        mappedDrive = objFso.GetDriveName(mappedDrivePath)
    
        serverDrive = objFso.Drives(mappedDrive).ShareName
    
        Debug.Print Replace(mappedDrivePath, mappedDrive, serverDrive)
    
        Set objFso = Nothing 

    If not, please provide some example to let us know what do you mean different path.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 7, 2018 6:55 AM
  • Hi,

    Problem is, Application.ActiveWorkbook.Path is showing incorrect path (not the one in which the Excel WorkBook is residing).


    Many Thanks & Best Regards, Hua Min

    Wednesday, March 7, 2018 8:25 AM
  • Hello HuaMin Chen,

    According to your previous threads, it seems you may operate multiple workbooks. I think this may cause the issue,

    if you open only workbook and then print the path, will it get error?

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 7, 2018 8:29 AM
  • Hi,

    No, this case is totally different from the issue in other threads (currently). To this case, I do no open more than one Excel file but the path is not correct.


    Many Thanks & Best Regards, Hua Min

    Wednesday, March 7, 2018 8:56 AM
  • Hello,

    So what's the path should be and what's result you got now?

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 7, 2018 8:57 AM
  • Hi,

    It is showing
    \\hkgclhctx.corp.zim.com\home$\...

    while correct path should be
    \\hkgmoss\sites\a4\IT\...


    Many Thanks & Best Regards, Hua Min

    Wednesday, March 7, 2018 9:14 AM
  • Hello HuaMin Chen,

    Where is the file stored? Is it stored in SharePoint? Could you detail how do you open the file? Where did you get the correct path?

    What's the result if you put the \\hkgclhctx.corp.zim.com\home$\... in browser? Will it open a page or a fold?

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, March 7, 2018 9:50 AM
  • Sorry that, by Application.ActiveWorkbook.Path

    Yesterday I got
    \\hkgclhctx.corp.zim.com\home$\...

    but today I had
    \\hfactx.corp.zim.com\ctx$\...

    within Citrix, to the same physical file inside Citrix. I know Citrix can be running physically on different Windows servers. Is there a way to ensure that we can ALWAYS HAVE ONE PHYSICAL PLACE (or path), to one file within Sharepoint?

    Many Thanks & Best Regards, Hua Min

    Wednesday, March 7, 2018 10:01 AM
  • Hello HuaMin Chen,

    This forum is for development issue related to Excel Object Model and it seems your issue caused by Citrix.

    Since Citrix is a third part systems, we would suggest you contact Citrix's support team for help.

    Thanks for understanding.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Jackson_1990 Thursday, March 8, 2018 1:21 PM
    • Unmarked as answer by Jackson_1990 Saturday, March 10, 2018 7:59 AM
    Thursday, March 8, 2018 9:00 AM
  • Hi,

    But currently the Excel file is existing within Sharepoint and this problem should be actually related to Microsoft product.


    Many Thanks & Best Regards, Hua Min

    Saturday, March 10, 2018 8:00 AM
  • Hello HuaMin Chen,

    I would suggest you check the file path via the user interface either than the VBA. Could you get correct path via user path? You could check the path from File->Properties->Advanced Properties->General->Location.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, March 12, 2018 3:24 AM
  • Hi,
    Where to choose

    File->Properties->Advanced Properties->General->Location

    below? Please also see relevant path (highlighted) I can see below (to my file).


    Many Thanks & Best Regards, Hua Min

    Tuesday, March 13, 2018 3:01 AM
  • Hello HuaMin Chen,

    Check this operation.

    Best Regards,

    Terry


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 13, 2018 6:20 AM
  • Hi,

    The path is correct below but why was it so strange (previously to the path)?


    Many Thanks & Best Regards, Hua Min


    Tuesday, March 13, 2018 6:26 AM
  • How did you configure SharePoint under Citrix?

    I make a test with SharePoint online, it output the expected path by "ActiveWorkbook.Path".


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by Jackson_1990 Tuesday, March 13, 2018 9:29 AM
    Tuesday, March 13, 2018 6:40 AM