Solved

I need a command to save and publish a db as an accde via vba.

Posted on 2012-03-28
8
570 Views
Last Modified: 2012-09-21
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?
0
Comment
Question by:akivashapiro
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
8 Comments
 
LVL 58
ID: 37777786
You can try:

SysCmd 603, strPathInputMdb, strPathOutputMde

However it cannot be the current MDB.

Jim.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 37777811
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.
0
 

Author Comment

by:akivashapiro
ID: 38358201
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.OpenCurrentDatabase 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!
0
Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

 
LVL 58
ID: 38363472
<<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.Application")
   
    '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.
0
 

Author Comment

by:akivashapiro
ID: 38363668
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.Application")

Any other ideas?

Thanks.
0
 
LVL 58
ID: 38367977
<<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.
0
 
LVL 58

Accepted Solution

by:
Jim Dettman (Microsoft MVP/ EE MVE) earned 500 total points
ID: 38391380
I'm afraid I've come up with not much.  Best you can do is put the DB in a trusted location and use the sendkey's approach and I have verified that the syscmd 603 call does not work beyond 2003.

Honestly, the MDE creation process is so problematic, I'm not sure why you'd want to automate it anyway.

Jim.
0
 

Author Comment

by:akivashapiro
ID: 38416114
Okay, thanks for trying.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question