Results 1 to 3 of 3
  1. #1
    cms9651 is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2011

    Disable autoexec macro access 2003 with VBScript

    Hi there, I need your appreciated help.

    I need disable "autoexec macro" access 2003 with VBS script.

    I try this code, I don't have error but the autoexec macro run with open db access and not run the OutputTo excel file:
    Set accDB = CreateObject("Access.Application")
          With accDB
             .visible = true
             .automationsecurity = 1
             .DoCmd.SelectObject acMacro, "autoexec"
             .DoCmd.OutputTo acOutputTable, "db", "xls", "C:\Inetpub\wwwroot\db\db.xls"
          End With
    Set accDB = Nothing
    Can you help me?
    Thks in advance-

  2. #2
    HiTechCoach's Avatar
    HiTechCoach is offline MS MVP - Access Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jul 2010
    Oklahoma, USA
    Not sure if it is possible to bypass the autoexec macro with VBS.

    You might be able to make a macro that runs the export. Open the database passing the macro to run on the command line.

    If it were my minee, I would make a separate front end that just does the export.
    Last edited by HiTechCoach; 06-20-2011 at 11:46 AM.

  3. #3
    pkstormy's Avatar
    pkstormy is offline Access/SQL Server Expert
    Windows XP Access 2003
    Join Date
    Mar 2010
    I'm not sure if this helps, but if I want to run a select, insert, update, etc.. statement against any of the tables in my MSAccess mdb using vb script, I do the following...

    Set WSNet = CreateObject("WScript.Network")
    varUserName = WSNet.UserName
    Set WSNet = Nothing
    Set MyConn = CreateObject("ADODB.Connection")
    Set RS = CreateObject("ADODB.Recordset")
    MyConn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\HelpForOthers\MyMDBFileName.mdb"
    Set RS = MyConn.Execute("SELECT * from MyTableName")
    ' or put whatever SQL code in place of the statement above...
    'ex: Set RS = MyConn.Execute("UPDATE MyTableName SET SomeFieldName ='" & "SomeValue" & "' WHERE ID ='" & SomeID & "'")
    'ex: set RS = MyConn.Execute("DELETE * from MyTable")
    'ex: set RS = MyConn.Execute("INSERT INTO MyTable (Field1, Field2) SELECT MyAccessLinkedOracleTable.Field1, 'MyAccessLinkedOracleTable.Field2
    'FROM MyAccessLinkedOracleTable")
    Set RS = Nothing
    Set MyConn = Nothing
    retval = msgbox("Table Updated")

    Again, I'm not sure if the above helps.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Runing Moduels from Macro's - Access 2003
    By damo1995 in forum Access
    Replies: 7
    Last Post: 02-10-2011, 03:40 AM
  2. Out of control loop in autoexec macro
    By accessnewbie in forum Programming
    Replies: 2
    Last Post: 08-19-2010, 04:31 PM
  3. Replies: 0
    Last Post: 05-07-2009, 02:32 PM
  4. Using parameter in autoexec macro
    By lchurch in forum Queries
    Replies: 0
    Last Post: 03-04-2009, 06:22 PM
  5. Replies: 1
    Last Post: 09-06-2006, 11:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Other Forums: Microsoft Office Forums