+ Reply to Thread
Results 1 to 12 of 12

bat file to open workbook

  1. #1
    Registered User
    Join Date
    11-20-2018
    Location
    greece
    MS-Off Ver
    2019
    Posts
    53

    bat file to open workbook

    i am coming today with another issue for my project
    i dont know if this topic is the right for my thread
    i have a bat file that open my workbook that is in a removable usb
    it work fine especially i have made an exe that run the bat file so all good
    but now i made a change to filename of my workbook i add beside of the main name a number considering like a version
    so my naim was test and my bat was opening but now is test1 so cant find the workbook to open it
    but tomorrow it might be test2 or test3 next day test4 and so on.
    the code is
    Please Login or Register  to view this content.
    any help how to make it see the main word test and like? i tried to put a quote as * but didn't work
    if there is another way to do i am glad to hear your suggestions
    Last edited by alansidman; 12-24-2022 at 03:17 AM.

  2. #2
    Forum Moderator alansidman's Avatar
    Join Date
    02-02-2010
    Location
    Steamboat Springs, CO
    MS-Off Ver
    MS Office 365 Version 2403 Win 11 Home 64 Bit
    Posts
    23,811

    Re: bat file to open workbook

    Code Tags Added
    Your post does not comply with Rule 2 of our Forum RULES. Use code tags around code.

    Posting code between [CODE]Please [url=https://www.excelforum.com/login.php]Login or Register [/url] to view this content.[/CODE] tags makes your code much easier to read and copy for testing, it also maintains VBA formatting.

    Highlight your code and click the # icon at the top of your post window. More information about these and other tags can be found at http://www.excelforum.com/forum-rule...rum-rules.html



    (I have added them for you today. Please take a few minutes to read all Forum Rules and comply in the future.)

    However, if you continue to not use code tags, you can expect to have your thread BLOCKED until you add them yourself.
    Alan עַם יִשְׂרָאֵל חַי


    Change an Ugly Report with Power Query
    Database Normalization
    Complete Guide to Power Query
    Man's Mind Stretched to New Dimensions Never Returns to Its Original Form

  3. #3
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    365 32bit Win
    Posts
    1,811

    Re: bat file to open workbook

    Even if you find matching files with a wildcard, you still need to provide a full filename.
    You could either find the file with your exe and pass it to the batch file, or put a alter the code within the batch file.

  4. #4
    Registered User
    Join Date
    11-20-2018
    Location
    greece
    MS-Off Ver
    2019
    Posts
    53

    Re: bat file to open workbook

    sorry for delay to answer it was a crazy week at work for Christmas you know
    i cant find the solution and ByteMarks i cant do much with exe because i produced the exe from a bat compiler
    the other is hard to do what you propose about alter the code. i google it and try to understand how works but nothing seems work for me

  5. #5
    Forum Contributor Gregor y's Avatar
    Join Date
    10-24-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2010 32-Bit
    Posts
    274

    Re: bat file to open workbook

    I'm having a hard time understanding the context of your project.
    • you have a usb drive
    • the project including the bat, the xlsb and the exe all live on the usb drive
    • the bat will run open test.xlsb file in excel and run a macro
    • someone else compiled the bat into the exe using some tool
    • you changed test.xlsb to test2.xlsb and now the exe will not find it

    Why are you using exe instead of just running the bat? Is there a constraint limiting you to exe/bat, or can you use ps1 instead?
    Obviously the fact that the project lives on usb is important to your story, but in which ways?
    Your code seems to start off as VBA, but the last line doesn't really fit. Also, the actions of the VBA code doesn't seem to fit the narrative.

  6. #6
    Registered User
    Join Date
    11-20-2018
    Location
    greece
    MS-Off Ver
    2019
    Posts
    53

    Re: bat file to open workbook

    thank you for your reply Gregor y. just say to forget the exe thing because it was just a way to show my project as application and not as a workbook. and exe beside of the bat file i can change the icon as it is show in the folder. thats for my purposes . the matter is the bat code that cant find with a wildcard or somehow else the workbook because i change the number after "test" . nowdays i went back to previous state and i rename my file just as test.xlsb so to be able to work until i will find the solution

  7. #7
    Registered User
    Join Date
    01-11-2023
    Location
    The Bahamas
    MS-Off Ver
    Itowerydu
    Posts
    1

    -

    I put the mod in Data/Custom. The model is made up only of triangles. I havent noticed any loose vertices. Would you mind looking at the file, and if you cant, is there someone else I can contact who will?

  8. #8
    Forum Expert
    Join Date
    07-23-2018
    Location
    UK
    MS-Off Ver
    365 32bit Win
    Posts
    1,811

    Re: bat file to open workbook

    Are you able to share the contents of test.bat?

  9. #9
    Forum Contributor Gregor y's Avatar
    Join Date
    10-24-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2010 32-Bit
    Posts
    274

    Re: bat file to open workbook

    The situation is: bat is a technology that has been carried forward from a time before when windows existed; which is at least partially why it's struggling to accomplish the task that you're asking it to do.

    You might be able to do something creative with a FOR loop through the files to pick out the one you're looking for; however if you are not restricted to a bat solution, then it is going to be a whole lot easier to use a more modern ps1 solution:
    Please Login or Register  to view this content.
    Then you can
    1. right click in the folder
    2. select New>Shortcut
    3. fill in the target input box with: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy RemoteSigned -File "Open-CurrentTestXLSB.ps1"
    4. click Next
    5. fill in the name input box with something useful like: Open Test.xlsb
    6. click Finish
    7. right click the new shortcut
    8. select Properties
    9. clear out the "Start In:" input box
    10. if you like you can click on Change Icon, and update that as well
    11. click OK

    Now you should have a runnable shortcut to the ps1 similar to how you had an exe with your personal icon.

    Note:
    • You may have to adjust the '.\test\BASIC\' in the ps1 file to be the correct folder to look in.
    • It doesn't currently find test.xlsb, but you could rename that to test0.xlsb and it would find it.

  10. #10
    Registered User
    Join Date
    11-20-2018
    Location
    greece
    MS-Off Ver
    2019
    Posts
    53

    Re: bat file to open workbook

    Sorry for so much big delay
    i tried your solution Gregor y but didn't run. maybe i didnt follow the instructions well
    but what i have done this month?
    i created an xlsm that call it open_pd.xlsm
    and in opening i wrote a code to run all the xlsb in the same folder. so i have only one xlsb so it doesnt mess with opening several files
    Please Login or Register  to view this content.
    so far works fine but my matter is my project to be perfect i would like to have that open_pd.xlsm to another folder
    for example my project is in folder office/basic
    and i would like the open_pd.xlsm to be in office/tools
    so have to adjust the folder path.
    any help?
    hope to be understood

  11. #11
    Forum Contributor Gregor y's Avatar
    Join Date
    10-24-2011
    Location
    Colorado, USA
    MS-Off Ver
    Excel 2010 32-Bit
    Posts
    274

    Re: bat file to open workbook

    does this help?

    Please Login or Register  to view this content.

  12. #12
    Registered User
    Join Date
    11-20-2018
    Location
    greece
    MS-Off Ver
    2019
    Posts
    53

    Re: bat file to open workbook

    of course and helped just it had to be not tools but basic
    now is the perfection and closing
    thank you all

+ 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. Open file into sheet in currently open workbook
    By stevecar144 in forum Excel General
    Replies: 1
    Last Post: 12-13-2019, 12:28 PM
  2. [SOLVED] Using Workbook.Open to open an excel file with a variable path
    By walt737 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-27-2019, 01:01 PM
  3. [SOLVED] Open workbook if not already open then close same file if was not already open
    By abhinavbinkar in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-30-2018, 02:50 AM
  4. [SOLVED] Check for existing File name, open if exist or open new workbook if not
    By COURTTROOPER in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 10-09-2017, 12:32 AM
  5. [SOLVED] Macro to open workbook with a suffix (need help to check if file is already open)
    By rossi_69 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-24-2017, 11:03 AM
  6. Want to open file, copy filtered data to new workbook and at save as new file
    By satishdu in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 05-25-2014, 12:39 PM
  7. Replies: 2
    Last Post: 04-12-2013, 07:56 PM

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