+ Reply to Thread
Results 1 to 4 of 4

Batch file don't work from vba

  1. #1
    Registered User
    Join Date
    05-28-2015
    Location
    France
    MS-Off Ver
    2007
    Posts
    3

    Question Batch file don't work from vba

    Hi everybody !
    I am a french student in mechanical design, living in Canada, and my last year internship is focused on building some macros (some huge macros) for my firm.
    I usually do my VBA work on CATIA (3D design), and I learned a lot in 2 month.
    But now, I am stuck in a dead-end (seems to, but I'm here to make it alive again ).
    First, my goal :
    I am creating a macro, from excel now, that creates new folders for the firm new jobs from a template folder.
    Until now, no problem. Everything works perfectly.
    But (yeah, here it is) for certain reasons, I have to run CATIA.
    It could be easy, but my firm has a "home improved" version, and this one opens only thanks to a shortcut, which we can find on every Desktop, or on the server.
    The shortcut is important, because his target is not only a .exe program, it is also the parameters and the environment of the program.

    I have the solution, well, almost.

    My opening sub works like this :
    It creates a batch file on the desktop, then run it, then kill it.
    Simple...

    Please Login or Register  to view this content.
    The batch file is created.
    The command is well inserted in it.
    The batch file work (a simple double click on it runs the command and open the good version of CATIA, Perfect)
    BUT when I try to run it through VBA, with the
    Please Login or Register  to view this content.
    it doesn't work !!!
    8 hours of pulling my hairs, trying to find a solution, and here I am.
    I thank you for reading me, but I'll thank you more if you find something that would help me ^^

    Have a nice day,
    Leyooooo

  2. #2
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Batch file don't work from vba

    I don't know why but sometimes you have to call a sub routine using:-

    Please Login or Register  to view this content.
    Other times you need to call it using:-

    Please Login or Register  to view this content.
    Questions

    1. is Shell a reserved word? change your name and see what happens

    2. is Yourself a variable? if not it should be "Yourself"

    3. you are using vbMinimizedFocus as a variable should this not be "vbMinimizedFocus"
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  3. #3
    Registered User
    Join Date
    05-28-2015
    Location
    France
    MS-Off Ver
    2007
    Posts
    3

    Re: Batch file don't work from vba

    Both of "shell" and "call shell" don't work, instantly replying an error message (command prompt don't find the shortcut, while it does when I lauch the .bat manually)
    Yourself is a variable (path of the mentioned shortcut)
    And vbMinimizedFocus is totally correct.

    My boss found a solution, lauching directly a file witch open with Catia, using the command :
    Please Login or Register  to view this content.
    I will test it, and I'll tell you if it is solved or not.

    Thank you mehmetcik for your really really quick answer !
    Leyooooo

    edit : well, didn't work ^^
    Last edited by leyooooo; 05-29-2015 at 11:49 AM.

  4. #4
    Registered User
    Join Date
    05-28-2015
    Location
    France
    MS-Off Ver
    2007
    Posts
    3

    Re: Batch file don't work from vba

    (edition reason : change a useless message to a conclusion message.)

    Well, I finally decided to forget about opening Catia from my excel Macro.
    I easily send to an opened Catia window the actions I want it to perform, but the opening part is kind of tricky.

    My solution : Ask the User to open the program himself before running the entire macro.

    It takes three clicks, and avoid the poor developer many days of questioning.
    In my opinion, a 5 seconds action don't need a macro.

    I'll thank the ones who read this thread, and the one who replied.
    See you soon, VBA's never over.
    Leyooooo


    (Thread marked as solved even if it is not, not really.)
    Last edited by leyooooo; 05-29-2015 at 12:51 PM.

+ 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. Need macro that opens .txt file in excel, run macros and save file in batch
    By khalidness in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-11-2014, 11:00 AM
  2. Replies: 0
    Last Post: 01-21-2014, 10:52 AM
  3. Batch file & macro to copy the latest file from a folder
    By paidlukkha in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 04-19-2013, 03:05 PM
  4. Replies: 2
    Last Post: 08-18-2006, 11:00 AM
  5. Why would FIND not work as a batch file in a DOS window?
    By denny in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 10-30-2005, 07:05 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