Results 1 to 6 of 6

Thread: Running VBA Sub on Startup

  1. #1
    Member
    Join Date
    2009-12
    Posts
    7
    Login to Give a bone
    0

    Default Running VBA Sub on Startup

    I am having trouble getting a VBA Script to run on startup. My acad.dvb loads automatically but my AcadStartup subroutine does not execute. It works fine when started manually so I know my code is good. Note this is ACADE 2014 on a Windows 8.1 machine. Thanks.

    This is the code:

    Public Sub AcadStartup()
    CopyReportFiles 'My code for copying reports format files.
    ThisDrawing.Utility.Prompt "Acad Startup Scripts Completed." & vbCrLf
    End Sub

    This is the command line output:

    Initializing VBA System...
    Loading VBA startup file...Loading Electrical modules...
    Loader application completed.

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,396
    Login to Give a bone
    0

    Default Re: Running VBA Sub on Startup

    Look at this thread and see if it helps.
    C:> ED WORKING....

  3. #3
    Member
    Join Date
    2009-12
    Posts
    7
    Login to Give a bone
    0

    Default Re: Running VBA Sub on Startup

    Ed,
    I had seen that post and none of it helped. ACAD.dvb loads fine, ACADStartup doesn’t execute.
    Not being unable to figure out why this won’t work I came up with a work around. I inserted a vbarun command within the Acad.lsp file to call my startup subroutine.
    In doing that I did discover that the vbarun command will not execute a macro with the name ACADStartup. It will return an execution error. Not sure why this is so but it seems to be the case on my machine.
    Thanks,
    Tim

  4. #4
    All AUGI, all the time arshiel88's Avatar
    Join Date
    2005-02
    Location
    Off the Grid
    Posts
    560
    Login to Give a bone
    0

    Default Re: Running VBA Sub on Startup

    Maybe it is not running because VBA module is not yet loaded. It is loaded automatically when you issue a command that needs it, as in the case of VBARUN in acad.lsp. Try including the "acvba.arx" in your Startup Suite.

    or;

    Quote Originally Posted by Ed Jobe View Post
    You can force vba to initialize by putting a line with "acvba.arx" in a txt file called "acad.rx". Create this with Notepad and save where acad.exe is.
    Last edited by arshiel88; 2014-02-10 at 06:11 AM.

  5. #5
    Member
    Join Date
    2009-12
    Posts
    7
    Login to Give a bone
    0

    Default Re: Running VBA Sub on Startup

    After digging around I figured out what was happening.
    When I created ACAD.dvb I must have copied a project that had a ThisDrawing.ACADStartup already in it. So the system didn’t know whether to run ThisDrawing.ACADStartup or MyModule.ACADStartup, which I created.
    Also, executing –vbarun from the command line didn’t know what to do either, hence the execution error.

    Thanks for your time.

  6. #6
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,396
    Login to Give a bone
    0

    Default Re: Running VBA Sub on Startup

    At least you got it working.
    C:> ED WORKING....

Similar Threads

  1. How can I make a startUp Exe for Startup AutoCAD
    By 740176597380946 in forum ARX
    Replies: 6
    Last Post: 2013-05-24, 05:36 AM
  2. Run sub at startup
    By jason907238 in forum Dot Net API
    Replies: 3
    Last Post: 2010-11-18, 06:16 PM
  3. TL on startup...
    By SupremeTaco in forum Revit Architecture - General
    Replies: 3
    Last Post: 2009-01-15, 04:08 PM
  4. VBA and Startup Suite
    By mboyer in forum VBA/COM Interop
    Replies: 10
    Last Post: 2007-01-16, 09:26 PM
  5. Startup Dialogue Box
    By martyk in forum AutoCAD General
    Replies: 1
    Last Post: 2005-02-02, 04:43 PM

Posting Permissions

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