MonteDelMar
asked on
VBA - Controlling Access from Word: Create .mdb & table without opening Access?
Hi All
Please can you tell me if, using VBA from Word, it is possible to create a new table in an existing Access database without opening Access? Currently I am using the attached code which, although it works fine, displays a macro security warning when it opens the database. I know that I can set the macro security in Access to low, or digitally sign the code, but am thinking that, if I can achieve this without actually opening Access, then I won't need to do either. Also, would Access need to be installed on a user's machine in order for this code to work? If so, is there a better way to do this so that it doesn't need to be installed?
Any help appreciated as always.
Please can you tell me if, using VBA from Word, it is possible to create a new table in an existing Access database without opening Access? Currently I am using the attached code which, although it works fine, displays a macro security warning when it opens the database. I know that I can set the macro security in Access to low, or digitally sign the code, but am thinking that, if I can achieve this without actually opening Access, then I won't need to do either. Also, would Access need to be installed on a user's machine in order for this code to work? If so, is there a better way to do this so that it doesn't need to be installed?
Any help appreciated as always.
Set objAccess = CreateObject("Access.Application")
With objAccess
.OpenCurrentDatabase (C:\Test\MyDB.mdb)
Set dBase = objAccess.CurrentDb
Set tdf = dbs.CreateTableDef("Contacts")
Set fld = tdf. _
CreateField("Surname", DB_Text, 50)
tdf.Fields.Append fld
dBase.TableDefs.Append tdf
End with
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER