Results 1 to 7 of 7

Thread: [RESOLVED] Help please with automating Excel & Access jobs

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Posts
    382

    Resolved [RESOLVED] Help please with automating Excel & Access jobs

    We are trying to automate, via Scheduled Tasks, the starting of Excel and Access. The Excel workbook contains a macro that runs when the workbook is opened. It downloads data, formats it and saves it in a folder as text. When finished, Excel shuts down. We have this much working.

    We now want to start Access and open a particular database. When Access starts, a macro should start automatically that imports the text data created by the previously run Excel workbook. Access should then shut down.

    What is the best way to do this via scheduled tasks so that Access does not start before the Excel program finishes?

    Thanks.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: Help please with automating Excel & Access jobs

    you could automate access from excel?
    either keep excel open until the access tasks finish then close excel or pass control to some access procedure and close excel, close access from its own code when finished
    alternatively you could use ADO to manipulate the database tables from excel, without opening access
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Posts
    382

    Re: Help please with automating Excel & Access jobs

    Thanks for quick reply. Because we want the option to run each process manually whenever wanted, I'd rather not mess with the VBA code in either the Excel download routine or the Access import routine. I need a way to delay starting Access until after the Excel routine finishes, and then launch the import routine independently afterwards. If I rename the import routine 'AutoExec', then every time someone opens the database, the import runs unless they depress 'shift' key, which I know will be forgotten sometimes. If a .vbs file would allow me to start import separately from opening the db, can you offer an example or point me to where I can get one?

    Thanks.

  4. #4
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Help please with automating Excel & Access jobs

    Here is another logic

    Create a very small program in vb6 which

    1) Opens Excel. When Excel Finishes, It will set off a Boolean variable to "True"
    2) The moment the value of the variable is true the small program will prompt if you want to launch Access. It will wait for your prompt for say 10 mins after which it will automatically launch Access.

    Sid
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  5. #5

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Posts
    382

    Re: Help please with automating Excel & Access jobs

    Getting a little wrapped around axle. I know this is easy but can't get it right. How do I start a .bat file (that contains everything needed including switches and other) from Excel using VBA?

    Thanks.

  6. #6
    Discovering Life Siddharth Rout's Avatar
    Join Date
    Feb 2005
    Location
    Mumbai, India
    Posts
    12,001

    Re: Help please with automating Excel & Access jobs

    What do you exactly want to do?

    If what I think you want to do then Bat file is a bad option

    Sid
    A good exercise for the Heart is to bend down and help another up...
    Please Mark your Thread "Resolved", if the query is solved


    MyGear:
    ★ CPU ★ Ryzen 5 5800X
    ★ GPU ★ NVIDIA GeForce RTX 3080 TI Founder Edition
    ★ RAM ★ G. Skill Trident Z RGB 32GB 3600MHz
    ★ MB ★ ASUS TUF GAMING X570 (WI-FI) ATX Gaming
    ★ Storage ★ SSD SB-ROCKET-1TB + SEAGATE 2TB Barracuda IHD
    ★ Cooling ★ NOCTUA NH-D15 CHROMAX BLACK 140mm + 10 of Noctua NF-F12 PWM
    ★ PSU ★ ANTEC HCG-1000-EXTREME 1000 Watt 80 Plus Gold Fully Modular PSU
    ★ Case ★ LIAN LI PC-O11 DYNAMIC XL ROG (BLACK) (G99.O11DXL-X)
    ★ Monitor ★ LG Ultragear 27" 240Hz Gaming Monitor
    ★ Keyboard ★ TVS Electronics Gold Keyboard
    ★ Mouse ★ Logitech G502 Hero

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2002
    Posts
    382

    Re: Help please with automating Excel & Access jobs

    I want to start a .bat file via a Windows Scheduled Task. This .bat file contains DOS commands that start other .bat files; e.g. start Excel /x "C:\Reports\Sales Data\SFTP.xlsm". There are multiple SFTP workbooks, one for each department. The /x switch allows me to examine the command line to see if SFTP.xlsm was started via .bat file or simply opened by a user. I need to know this because I don't want any Excel messages displayed that require a user response if the workbook was opened by Windows as a scheduled task.

    The SFTP.xlsm workbook, when opened, automatically runs a macro that downloads data and places that data in a file. Before exiting, an 'Application.Quit' is performed and another subroutine starts that opens the Access database and runs a macro; e.g. start "C:\Program Files\access97\Microsoft Office\Office\MSACCESS.EXE" "C:\Reports\Sales Data\Database.accdb" /Excl /nostartup /x AutoTask where 'AutoTask' is the macro that imports the downloaded data.

    In a nut shell, I want to schedule a job stream that runs at a certain time each day. This job stream starts multiple Excel instances, each downloading some data, exiting, and opening a separtate Access database. When opened, Access imports the data, exits, and then sends an email advising of the status. I want to keep the VBA code in the Excel and Access modules separate.

    I would sure appreciate some suggestion on a clean way to do this.

Posting Permissions

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



Click Here to Expand Forum to Full Width