+ Reply to Thread
Results 1 to 17 of 17

Macro not more working with Win11?

Hybrid View

  1. #1
    Registered User
    Join Date
    10-27-2021
    Location
    Vienna
    MS-Off Ver
    2019
    Posts
    29

    Macro not more working with Win11?

    Hello, i have the following small macro in my excel running fine with on Win10:
    (its simply a button in the xlsm and when pressed the exe-file gets executed)
    Sub calcConstr()
        Dim FN As String
        FN = Application.ThisWorkbook.Path
        FN = FN + "\constrCalc3.exe"
        Shell FN, vbNormalFocus
    End Sub
    But when i run the same xlsm and press the button i get this error:
    2022-03-10 21_13_08-Microsoft Visual Basic.png

    They only difference between the computers that on the one is running win11 and on the other win10
    (excel is with 365 on both the same)

    What can be the reason that this is not anymore working on the win11-pc?
    Last edited by Rapid1898; 03-10-2022 at 05:08 PM.

  2. #2
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,268

    Re: Macro not more working with Win11?

    Administrative Note:

    Welcome to the forum.

    We would very much like to help you with your query, however you need to include code tags around your code.

    Please take a moment to add the tags. Posting code between [code] [/code] tags makes your code much easier to read and copy for testing, and it also maintains VBA formatting.

    Please see Forum Rule #2 about code tags and adjust accordingly. Click on Edit to open your post, then highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found here

    I have added them for your because the section of code was very short. However, please take the time to review our rules. There aren't many, and they are all important.
    Jeff
    | | |會 |會 |會 |會 | |:| | |會 |會
    Read the rules
    Use code tags to [code]enclose your code![/code]

  3. #3
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,268

    Re: Macro not more working with Win11?

    Quote Originally Posted by Rapid1898 View Post
    They only difference between the computers that on the one is running win11 and on the other win10
    I have seen dozens of questions like this, and that is never the only difference.

    N = FN + "\constrCalc3.exe"
    Does constrCalc3.exe actually exist in the same folder with the Excel workbook that is running this code?

  4. #4
    Registered User
    Join Date
    10-27-2021
    Location
    Vienna
    MS-Off Ver
    2019
    Posts
    29

    Re: Macro not more working with Win11?

    Thanks for your reply - yes the the exe-file is definetely in the same folder as the excel-sheet where the button is pressed.

  5. #5
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,268

    Re: Macro not more working with Win11?

    The way I would troubleshoot this is to reproduce the Shell command in the Windows cmd window.

    Add this line of code before the Shell command:

    Debug.Print FN
    Go to the Immediate window and copy the full path that was just printed.
    In the Windows search bar type cmd to bring up a command window
    Type a quote " then Paste in the command window (which will paste the path you just copied) then type another "
    Hit Enter, and report back on what happens.

    notfound.jpg

  6. #6
    Registered User
    Join Date
    10-27-2021
    Location
    Vienna
    MS-Off Ver
    2019
    Posts
    29

    Re: Macro not more working with Win11?

    I changed the code so it looks like this:

    Sub calcConstr()
        Dim FN As String
        FN = Application.ThisWorkbook.Path
        Debug.Print FN
        FN = FN + "\constrCalc4.exe"
        Shell FN, vbNormalFocus
    End Sub
    Then i started the button i get this message-box
    Attachment 772061

    But nothing else opened - and i can so no path-output anywhere to make the checks you described.

    I tried to click on the Debug-Button - then i see the following (but again no path to check):
    Attachment 772062

  7. #7
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,268

    Re: Macro not more working with Win11?

    Quote Originally Posted by Rapid1898 View Post
    Then i started the button i get this message-box
    Attachment 772061

    But nothing else opened - and i can so no path-output anywhere to make the checks you described.

    I tried to click on the Debug-Button - then i see the following (but again no path to check):
    Attachment 772062
    Your images didn't show up.

    There is a bug in our image attachment feature. To attach an image, first click Go Advanced under your edit box. Then go ahead to press the image icon and attach your image.

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    49,113

    Re: Macro not more working with Win11?

    I did it like this:

    Option Explicit
    
    Sub calcConstr()
        Dim FN As String
        Debug.Print "FN: " & FN
        FN = Application.ThisWorkbook.Path
        Debug.Print "FN: " & FN
        FN = FN + "\constrCalc3.exe"
        Debug.Print "FN: " & FN
        Shell FN, vbNormalFocus
    End Sub
    
    FN:
    FN: E:\...\Downloads
    FN: E:\...\Downloads\constrCalc3.exe
    That way, you can see how the contents of the variable FN builds up.

    The output will appear in the Immediate Window in the VB Editor. If you can't see it, press Ctrl-G.

    Are you sure that the full path exists? And that there are no trailing spaces on the folder name(s)? Could it be something to do with permissions? Can you run the .exe file from that folder?
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  9. #9
    Registered User
    Join Date
    10-27-2021
    Location
    Vienna
    MS-Off Ver
    2019
    Posts
    29

    Re: Macro not more working with Win11?

    Thanks for your help - with the following line i was able to output the path-informaton

    MsgBox "The value of FN is " & FN, vbInformation
    I have to check this and get back to you asap.
    Last edited by 6StringJazzer; 03-11-2022 at 09:57 AM. Reason: fixed error in code tags

  10. #10
    Registered User
    Join Date
    10-27-2021
    Location
    Vienna
    MS-Off Ver
    2019
    Posts
    29

    Re: Macro not more working with Win11?

    Interesting - when i cklick on the image-attachement it works fine and i can see the image.
    But i will change this.

  11. #11
    Registered User
    Join Date
    10-27-2021
    Location
    Vienna
    MS-Off Ver
    2019
    Posts
    29

    Re: Macro not more working with Win11?

    In the meantime i was able to get the informaton in excel -

    I am starting the excel-sheet locally on this place:
    Attachment 772943

    And in excel it shows me this path when pressing the macro-button:
    Its obvious that he can愒 find this path...
    Attachment 772945

    What is the reason why he shows here this path "https://d.docs.live.net/" and not the locally path where the excel is started?

  12. #12
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,268

    Re: Macro not more working with Win11?

    Here are your images inline in a post, inserted by following my instructions:

    4.jpg

    2.jpg

  13. #13
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,268

    Re: Macro not more working with Win11?

    It appears that this folder is in a OneDrive synced folder. If so, the .Path name will be the location where it is stored in the OneDrive cloud, not the path on your local machine. (This is one reason I don't like OneDrive. I don't have this problem with Dropbox.) I fixed this same problem for someone who worked for me by moving the Excel file out of the OneDrive folder into a folder on the local drive.

    Like I said, I have seen dozens of questions like this, and that is never the only difference. You evidently did not use OneDrive on the Windows 10 machine.

  14. #14
    Registered User
    Join Date
    10-27-2021
    Location
    Vienna
    MS-Off Ver
    2019
    Posts
    29

    Re: Macro not more working with Win11?

    Ok i see - thanks for the answer -
    And there is no way to get the local path in VBA when storing the file in a OneDrive synced folder?

  15. #15
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,268

    Re: Macro not more working with Win11?

    There are ways but I've never done it. It's a little complicated. Normally we do not link to other sites but here is a page with a solution to your exact problem. There are multiple options discussed here so you will have to decide which one will work best for you.

  16. #16
    Registered User
    Join Date
    10-27-2021
    Location
    Vienna
    MS-Off Ver
    2019
    Posts
    29

    Re: Macro not more working with Win11?

    Thanks for your help - i think this is to complicated to solve.

  17. #17
    Administrator 6StringJazzer's Avatar
    Join Date
    01-27-2010
    Location
    Tysons Corner, VA, USA
    MS-Off Ver
    MS 365 Family 64-bit 2505
    Posts
    27,268

    Re: Macro not more working with Win11?

    The way I solved it for my employee was to move the folder out one OneDrive to a regular C: drive folder.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Macro working in windows machine but not working in MAC
    By amitmodi_mrt in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 5
    Last Post: 11-16-2017, 11:26 AM
  2. [SOLVED] Macro working in windows machine but not working in MAC
    By amitmodi_mrt in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-15-2017, 02:12 PM
  3. Copied working macro to new workbook, but no longer working
    By twisted31 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 10-23-2017, 06:17 PM
  4. [SOLVED] Macro working perfectly on MS office x86 but not working on x64
    By alexgoaga in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 09-26-2017, 05:04 AM
  5. Well working simple macro now not working-open folder
    By jomili in forum Word Programming / VBA / Macros
    Replies: 6
    Last Post: 07-05-2017, 08:24 AM
  6. [SOLVED] help index and match macro not working but formula working??
    By JEAN1972 in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 02-28-2016, 06:37 AM
  7. Hide Columns Macro - Working on Windows not working on Mac OSX
    By bcadar in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 01-08-2016, 09:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1