akivashapiro
asked on
I need a command to save and publish a db as an accde via vba.
I posted this before, but I was hoping someone might have some new ideas.
I need a command to save and publish a db as an accde via vba.
Any thoughts?
I need a command to save and publish a db as an accde via vba.
Any thoughts?
DO you mean you're trying to create an accde from the database you're currently in?
I don't think that is possible.
It is possible to create an mde of a different database in code.
I don't think that is possible.
It is possible to create an mde of a different database in code.
ASKER
Sorry for the long delay.
I'm using MS Access 2010.
I create a new database and I tried
SysCmd 603, strPathInputMdb, strPathOutputMde
It does nothing. Also, 603 is not a value listed for SysCmd in the help or drop down enumerations. It may be a hidden command, but it does nothing and generates no error.
I then tried creating a new application instance:
Dim appAccess As New Access.Application
appAccess.OpenCurrentDatab ase sourceDB$ 'where sourceDB is a different DB from the currentDb
appAccess.RunCommand acCmdMakeMDEFile
This returns the same error message as when trying to execute acCmdMakeMDEFile on the current db.
Both of you suggest that what I want to do can be accomplished - albeit in a differrent db. If you could attach some code you've tested that would be great and appreciated.
Thanks!
I'm using MS Access 2010.
I create a new database and I tried
SysCmd 603, strPathInputMdb, strPathOutputMde
It does nothing. Also, 603 is not a value listed for SysCmd in the help or drop down enumerations. It may be a hidden command, but it does nothing and generates no error.
I then tried creating a new application instance:
Dim appAccess As New Access.Application
appAccess.OpenCurrentDatab
appAccess.RunCommand acCmdMakeMDEFile
This returns the same error message as when trying to execute acCmdMakeMDEFile on the current db.
Both of you suggest that what I want to do can be accomplished - albeit in a differrent db. If you could attach some code you've tested that would be great and appreciated.
Thanks!
<<It does nothing. Also, 603 is not a value listed for SysCmd in the help or drop down enumerations. It may be a hidden command, but it does nothing and generates no error.>>
603 is an undocumented call that worked in earlier versions
<<I then tried creating a new application instance:
Dim appAccess As New Access.Application
>>
That approach would work, but you don't want to open the database.
Try this instead:
Function GenerateMDEFile(MyPath As String)
On Error GoTo FailedMDE
Dim NAcc As Access.Application
Set NAcc = CreateObject("Access.Appli cation")
'The following lines simulate accepting the default
'name, clicking Make MDE, and clicking Save
SendKeys MyPath & "{Enter}{Enter}"
SendKeys "{Enter}"
NAcc.DoCmd.RunCommand acCmdMakeMDEFile
Goto Done
FailedMDE:
msgbox "Failed" & vbcrlf & err.description
Done:
On Error Resume Next
Set NAcc = Nothing
End Function
Note the DB is not opened. This should work as it is a solution posted by Rocki Roads here on EE.
However, I don't know that I'd be trying to automate MDE creation; it's so problematic. A MDB must be fully compiled, compacted and repaired, and be free from errors in order to convert to a MDE.
I typically create a brand new DB, import everything, check references, then compile, and follow with a C&R before trying to make a MDE.
Many in the past have tried to automate that whole process and without much luck (it's simply easier to do it manually).
Jim.
603 is an undocumented call that worked in earlier versions
<<I then tried creating a new application instance:
Dim appAccess As New Access.Application
>>
That approach would work, but you don't want to open the database.
Try this instead:
Function GenerateMDEFile(MyPath As String)
On Error GoTo FailedMDE
Dim NAcc As Access.Application
Set NAcc = CreateObject("Access.Appli
'The following lines simulate accepting the default
'name, clicking Make MDE, and clicking Save
SendKeys MyPath & "{Enter}{Enter}"
SendKeys "{Enter}"
NAcc.DoCmd.RunCommand acCmdMakeMDEFile
Goto Done
FailedMDE:
msgbox "Failed" & vbcrlf & err.description
Done:
On Error Resume Next
Set NAcc = Nothing
End Function
Note the DB is not opened. This should work as it is a solution posted by Rocki Roads here on EE.
However, I don't know that I'd be trying to automate MDE creation; it's so problematic. A MDB must be fully compiled, compacted and repaired, and be free from errors in order to convert to a MDE.
I typically create a brand new DB, import everything, check references, then compile, and follow with a C&R before trying to make a MDE.
Many in the past have tried to automate that whole process and without much luck (it's simply easier to do it manually).
Jim.
ASKER
Thanks Jim for the response.
-> In order to do this:
'The following lines simulate accepting the default
'name, clicking Make MDE, and clicking Save
SendKeys MyPath & "{Enter}{Enter}"
SendKeys "{Enter}"
-> There must be a dialog box to accept the input.
-> This line does not generate a dialog box in Access 2010. I think it did in 2003.
Set NAcc = CreateObject("Access.Appli cation")
Any other ideas?
Thanks.
-> In order to do this:
'The following lines simulate accepting the default
'name, clicking Make MDE, and clicking Save
SendKeys MyPath & "{Enter}{Enter}"
SendKeys "{Enter}"
-> There must be a dialog box to accept the input.
-> This line does not generate a dialog box in Access 2010. I think it did in 2003.
Set NAcc = CreateObject("Access.Appli
Any other ideas?
Thanks.
<<Any other ideas?>>
SendKey's sequence is a bit different. You need Alt/F, then O to bring up the open file dialog.
But the other thing that trips this up is the "Enable content" button. This method is too fragile and the wrong approach.
Let me see what I can come up with.
Jim.
SendKey's sequence is a bit different. You need Alt/F, then O to bring up the open file dialog.
But the other thing that trips this up is the "Enable content" button. This method is too fragile and the wrong approach.
Let me see what I can come up with.
Jim.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Okay, thanks for trying.
SysCmd 603, strPathInputMdb, strPathOutputMde
However it cannot be the current MDB.
Jim.