Need some additional help with this script to update front ends

Nick67 was gracious to share a method to automatically update front ends in this post:
http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_27319609.html


I am trying to get this to work in my environment... I am almost there but needs a little help with my settings... (at least I hope that is all it is....)

1st question:  My app is very small and copies very quickly.  Is there a way to hide the command window from displaying.  It blinks on and off in about 2 seconds and I can see it confusing some people, WHATWAZZAT!?

2nd question:  I have a mixed environment of Access 2000, 2007 and soon to be 2010.
Access 2000 starts up pretty quickly but I noticed that Access 2007 opens to main page ("Getting Started with Microsoft Office Access") and then goes into the database.  Is there any way to prevent that from showing... ?

3rd question:  This will not run with the Access2007 runtime version.  It bombs with line 112:  ActiveX can't create object "Access.Application"   Is there another way to do it for use with the run time?  Unfortunately we have many desktops with Office Standard (No Access installed.)


Thanks!


'declare an object to be a filesystem object
Public fs
'declare an object to be a MS Access application
Public acApp
 'declare a wscript shell
Public WshShell

Main()

'-------------------------------------------------------------------------------------------------------------------------------------------
Sub Main()
dim MyConn
dim MyConn1
Dim LocalSplit
Dim ServerSplit
Dim x

OpenCmdWindow()



CheckDeployment()

If fs.FileExists("G:\General\database\TimeSheet\deploy\ver.txt") then
    Set MyConn= fs.OpenTextFile("G:\General\database\TimeSheet\deploy\ver.txt",1, true)
    ServerSplit = Split(MyConn.readall, ".")
    MyConn.Close
end if

If fs.FileExists("U:\db\TimeSheet\ver.txt") then
    Set MyConn1= fs.OpenTextFile("U:\db\TimeSheet\ver.txt",1, true)
    LocalSplit = Split(MyConn1.readall, ".")
    MyConn1.Close
else
    LocalSplit =Split("0.0.0.0", ".")
end if

set myconn = nothing
set myconn1 = nothing

If UBound(LocalSplit) <> UBound(ServerSplit) Then
        Call CopyUpdate()
        FireDB()
        Exit Sub
End If

For x = 0 To UBound(LocalSplit)
    If cint(ServerSplit(x)) > cint(LocalSplit(x)) Then
        Call CopyUpdate()
        FireDB()
        Exit Sub
    End If
Next

if fs.FileExists("U:\db\TimeSheet\time_capture_fe_Backup.mdb") then
    Call KillBad()
    Call CopyUpdate()
    FireDB()
    Exit Sub
end if


FireDB()

end sub

'------------------------------------------------------------------------------------
private Sub CopyUpdate()
Dim BuiltPath
Dim userpath

userpath= "G:\General\database\TimeSheet\deploy\time_capture_fe.mdb"
BuiltPath = "U:\db\Timesheet"
TempPath = "U:\db\Timesheet\temp"

If fs.FolderExists(BuiltPath) = False Then
    fs.CreateFolder BuiltPath
    fs.copyfile "G:\General\database\TimeSheet\deploy\dynaPFD.dll", "U:\db\TimeSheet\dynaPDF.dll", -1
    fs.copyfile "G:\General\database\TimeSheet\deploy\strStorage.dll", "U:\db\TimeSheet\strStorage.dll", -1
    
End If

fs.copyfile userpath, "U:\db\Timesheet\time_capture_fe.mdb", -1
fs.copyfile "G:\General\database\TimeSheet\deploy\ver.txt", "U:\db\TimeSheet\ver.txt", -1


If fs.FolderExists(TempPath) = False Then
    fs.CreateFolder TempPath
End if

End Sub
'-----------------------------------------------------------------------------------------

Function CheckDeployment() 
Dim BuiltPath
BuiltPath = "U:\db\Timesheet\time_capture_fe.mdb"

If fs.FileExists(BuiltPath) = False Then
    Call CopyUpdate()
End If



End Function
'---------------------------------------------------------------------------------------
sub FireDB

CloseCmdWindow()
dim PathToMDE
PathToMDE = "U:\db\Timesheet\time_capture_fe.mdb"

Set acApp=CreateObject("Access.Application")
acApp.usercontrol=true
acApp.DoCmd.RunCommand (10) 'accmdappmaximize
acApp.DoCmd.Hourglass True


'acApp.AutomationSecurity=1  ' low
acApp.OpenCurrentDatabase PathToMDE
acApp.DoCmd.Hourglass false
Set acApp=Nothing
Set fs = nothing

end sub

'-------------------------------------------------------------
sub OpenCmdWindow()
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd.exe"
WScript.Sleep 10
WshShell.AppActivate "c:\windows\system32\cmd.exe"
WScript.Sleep 100
WshShell.SendKeys "Starting....wait patiently...."


end sub

 '------------------------------------------------------------
sub CloseCmdWindow()
dim oshell
dim oWmg
dim strWndprs
dim objQResult

WScript.Sleep 100

Set oShell = CreateObject("WScript.Shell") 
Set oWmg = GetObject("winmgmts:") 

strWndprs = "select * from Win32_Process where name='cmd.exe'" 
Set objQResult = oWmg.Execquery(strWndprs) 

For Each objProcess In objQResult 

intReturn = objProcess.Terminate(1) 

Next



'WshShell.AppActivate "c:\windows\system32\cmd.exe"
'WScript.Sleep 100
'WshShell.SendKeys "{enter}"
' WshShell.SendKeys "exit"
' WshShell.SendKeys "{enter}"
end sub

'------------------------------------------------------------
Private sub KillBad()

If fs.FileExists("U:\db\Timesheet\time_capture_fe.mdb_Backup.mdb") Then
    fs.DeleteFile "U:\db\Timesheet\time_capture_fe.mdb_Backup.mdb", True
end if

If fs.FileExists("U:\db\Timesheet\time_capture_fe.mdb") Then
    fs.DeleteFile "U:\db\Timesheet\time_capture_fe.mdb", True
end if

If fs.FileExists("U:\db\Timesheet\time_capture_fe.ldb") Then
    fs.DeleteFile "U:\db\Timesheet\time_capture_fe.ldb", True
end if



end sub

Open in new window

snyperjAsked:
Who is Participating?
 
Nick67Connect With a Mentor Commented:
Usercontrol = true overrides visible
http://msdn.microsoft.com/en-us/library/aa663049(v=office.11).aspx
I also have some popup modal messages that make my app error if I try to keep it hidden

You can try pushing these two line farther down into the FireDB() sub
The sleep command is in milliseconds
WScript.Sleep 1000
acApp.usercontrol=true

You can try leaving the usercontrol = true out of the script and put it in the app's autoexec, too

But for me, that can't fly because of the modal message box I have

YMMV
0
 
Nick67Commented:
This sub opens the command window

sub OpenCmdWindow()
set WshShell = WScript.CreateObject("WScript.Shell")
WshShell.Run "cmd.exe"
WScript.Sleep 10
WshShell.AppActivate "c:\windows\system32\cmd.exe"
WScript.Sleep 100
WshShell.SendKeys "Starting....wait patiently...."


end sub


It's only purpose was to provide some visual feedback to the user that the process was going
Line 18 opens it ---> OpenCmdWindow()
Line 108 closes it ---> CloseCmdWindow()
Comment that stuff out and that part is golden
0
 
Nick67Commented:
<2nd question:  I have a mixed environment of Access 2000, 2007 and soon to be 2010.
Access 2000 starts up pretty quickly but I noticed that Access 2007 opens to main page ("Getting Started with Microsoft Office Access") and then goes into the database.  Is there any way to prevent that from showing... ?>

That's tougher
Conceivably at line 113 you could put in
acApp.Visible = false
That would hide things
You'd need something in the app's autoexec or initial form's load to unhide it,  but it should be doable
0
Cloud Class® Course: Microsoft Office 2010

This course will introduce you to the interfaces and features of Microsoft Office 2010 Word, Excel, PowerPoint, Outlook, and Access. You will learn about the features that are shared between all products in the Office suite, as well as the new features that are product specific.

 
Nick67Commented:
<This will not run with the Access2007 runtime version. >
It's doable.
Have a look for the header Automating Access Runtime a quarter of the way down here
http://support.microsoft.com/kb/317113
http://support.microsoft.com/kb/295179/EN-US
<The Access Runtime must be started with a database. Because of this requirement, if you want to automate the Access Runtime, you must start the Msaccess.exe and specify a database to open. After you use GetObject to retrieve the Application object, you can proceed with automating the Access Runtime. If you try to automate the Access Runtime with the New keyword or with CreateObject, you will receive an error message >

So this will have to change
Set acApp=CreateObject("Access.Application")

However, since it is just firing the db
dim PathToMDE
PathToMDE = "U:\db\Timesheet\time_capture_fe.mdb"

Set acApp=CreateObject("Access.Application")
acApp.usercontrol=true
acApp.DoCmd.RunCommand (10) 'accmdappmaximize
acApp.DoCmd.Hourglass True
'acApp.AutomationSecurity=1  ' low
acApp.OpenCurrentDatabase PathToMDE
acApp.DoCmd.Hourglass false
Set acApp=Nothing

It could conceivably be preceeded with a shell command
Shell "WhateverThePathToTheRuntimeIs\MsAccess.exe" & chr(34) & PathToMDE & Chr(34)
and changed to
Set acApp=GetObject("Access.Application")
0
 
snyperjAuthor Commented:
Good stuff... I will check it all out when I get in the office tomorrow.  Thanks for the help.  

Any idea on what I could put in the form load event of my initial form that WOULD unhide Access?

"That's tougher
Conceivably at line 113 you could put in
acApp.Visible = false
That would hide things
You'd need something in the app's autoexec or initial form's load to unhide it,  but it should be doable"

0
 
Nick67Commented:
Should be as simple as Application.Visible = true
0
 
snyperjAuthor Commented:
ok, I will try that as well.
0
 
snyperjAuthor Commented:

"That's tougher
Conceivably at line 113 you could put in
acApp.Visible = false
That would hide things
You'd need something in the app's autoexec or initial form's load to unhide it,  but it should be doable"




I changed the .vbs file as shown below, but the acApp.visible seems to do nothing?  The db still opens as it did before?

Set acApp=CreateObject("Access.Application")
acApp.Visible = False
acApp.usercontrol=true
acApp.DoCmd.RunCommand (10) 'accmdappmaximize
acApp.DoCmd.Hourglass True
0
 
snyperjAuthor Commented:
Thanks.  I haven't tried the runtime version yet, as it is a lesser priority, but I think this will work for what I am trying to do!  Great work Nick67.
0
 
Nick67Commented:
You're welcome!
0
 
snyperjAuthor Commented:
Help.... I found out late Friday that some users will start using the runtime on Monday.  I am having some trouble with that version of the script.  Followup posted here: http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_27326491.html
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.