Printable Version of Topic

Click here to view this topic in its original format

UtterAccess Forums _ ASP and VBScript _ Vbs To Open Access Maxmized

Posted by: ry94080 Dec 21 2018, 10:59 AM

Hi all,

I have a vbs file that opens up my access database. The main form that opens up on DB open has this command: DoCmd.RunCommand acCmdAppMaximize and seems to work just fine when I open the db directly. It maximizes the actual access app.

However when I open the same db via VBS, it doesn't maximize it

CODE
Function OpenDB(sRemoteDB, sLocalDB)

Dim bRun
Dim o


If FileExits(sLocalDB) = False Then
    If FileExits(sRemoteDB) = True Then
        bRun = CopyFileTo(sRemoteDB, sLocalDB)
    Else
        bRun = False
    End If
Else
    bRun = True
End If

If bRun Then
    
    bRun = CopyFileTo(sRemoteDB, sLocalDB)

    If bRun Then
        Set WshShell = CreateObject("WScript.Shell")
        If Len(sWorkGroupFile & "") > 0 Then
        'WshShell.Run "MSAccess.exe " & Chr(34) & sLocalDB & Chr(34)
    Set o = CreateObject("Access.Application")
    o.AutomationSecurity = 1 ' set macro security LOW.
    o.OpenCurrentDatabase sLocalDB
    o.RunCommand acCmdAppMaximize
    o.UserControl = True
    Set o = Nothing


       Else
        'WshShell.Run "MSAccess.exe " & Chr(34) & sLocalDB & Chr(34)
    Set o = CreateObject("Access.Application")
    o.AutomationSecurity = 1 ' set macro security LOW.
    o.OpenCurrentDatabase sLocalDB    
    o.RunCommand acCmdAppMaximize
    o.UserControl = True
    Set o = Nothing



       End If
     End If
    
    If bRun Then
        bRun = (Err.Number = 0)
    End If
End If
OpenDB = bRun

End Function

Posted by: cheekybuddha Dec 21 2018, 11:08 AM

Hi,

Try changing:

CODE
' ...
    o.RunCommand acCmdAppMaximize
' ...

to:
CODE
' ...
    o.DoCmd.RunCommand acCmdAppMaximize
' ...

Posted by: ry94080 Dec 21 2018, 11:19 AM

Tried. No luck.

confused.gif

Posted by: ry94080 Dec 21 2018, 11:23 AM

Figured it out!!!!!

Had to define a constant

const acCmdAppMaximize = 10

Posted by: cheekybuddha Dec 21 2018, 11:24 AM

thumbup.gif