ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Automate Access (https://www.excelbanter.com/excel-programming/282661-automate-access.html)

hlam

Automate Access
 
My excel file is to close itself after access is called, however the access
file is not opened in full window size. How can I modify the code in order
to have the access window in full size?

Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.OpenCurrentDatabase ("D:\db1.mdb")
.Visible = True
End With

Set accessApp = Nothing

ThisWorkbook.Close

End Sub



immanuel[_2_]

Automate Access
 
Try:

accessApp.WindowState = -4137

/i.

"hlam" wrote in message news:DAwtb.52959$jy.12728@clgrps13...
My excel file is to close itself after access is called, however the

access
file is not opened in full window size. How can I modify the code in

order
to have the access window in full size?

Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.OpenCurrentDatabase ("D:\db1.mdb")
.Visible = True
End With

Set accessApp = Nothing

ThisWorkbook.Close

End Sub





Tom Ogilvy

Automate Access
 
Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.OpenCurrentDatabase ("D:\db1.mdb")
.Visible = True
.DoCmd.RunCommand acCmdAppMaximize
End With

Set accessApp = Nothing

ThisWorkbook.Close

End Sub
--
Regards,
Tom Ogilvy



hlam wrote in message news:DAwtb.52959$jy.12728@clgrps13...
My excel file is to close itself after access is called, however the

access
file is not opened in full window size. How can I modify the code in

order
to have the access window in full size?






Tom Ogilvy

Automate Access
 
I believe that is the Excel method, but it is not available in Access:

http://support.microsoft.com/default...90&Product=acc
ACC2000: How to Use Visual Basic for Applications to Minimize, Maximize, and
Restore Access

http://support.microsoft.com/default...34&Product=acc
ACC: How to Minimize, Maximize, and Restore MS Access 95/97

At least not in Acc 95 - 2000

--
Regards,
Tom Ogilvy


immanuel wrote in message
...
Try:

accessApp.WindowState = -4137

/i.

"hlam" wrote in message news:DAwtb.52959$jy.12728@clgrps13...
My excel file is to close itself after access is called, however the

access
file is not opened in full window size. How can I modify the code in

order
to have the access window in full size?

Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.OpenCurrentDatabase ("D:\db1.mdb")
.Visible = True
End With

Set accessApp = Nothing

ThisWorkbook.Close

End Sub







immanuel[_2_]

Automate Access
 
Thanks for the correction, Tom. :)

In 2003, it seems that you can just call Appliation.DoCmd.Maximize. Is this
not the case previous versions?

Regards,
Immanuel

"Tom Ogilvy" wrote in message
...
I believe that is the Excel method, but it is not available in Access:

http://support.microsoft.com/default...90&Product=acc
ACC2000: How to Use Visual Basic for Applications to Minimize, Maximize,

and
Restore Access

http://support.microsoft.com/default...34&Product=acc
ACC: How to Minimize, Maximize, and Restore MS Access 95/97

At least not in Acc 95 - 2000

--
Regards,
Tom Ogilvy


immanuel wrote in message
...
Try:

accessApp.WindowState = -4137

/i.

"hlam" wrote in message

news:DAwtb.52959$jy.12728@clgrps13...
My excel file is to close itself after access is called, however the

access
file is not opened in full window size. How can I modify the code in

order
to have the access window in full size?

Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.OpenCurrentDatabase ("D:\db1.mdb")
.Visible = True
End With

Set accessApp = Nothing

ThisWorkbook.Close

End Sub









Tom Ogilvy

Automate Access
 
That maximizes the active window within the application window, not the
application window. I understood the requirement to be the application
window. That is the behavior in access 97 and 2000. I don't think it would
change in later versions.

--
Regards,
Tom Ogilvy

immanuel wrote in message
...
Thanks for the correction, Tom. :)

In 2003, it seems that you can just call Appliation.DoCmd.Maximize. Is

this
not the case previous versions?

Regards,
Immanuel

"Tom Ogilvy" wrote in message
...
I believe that is the Excel method, but it is not available in Access:


http://support.microsoft.com/default...90&Product=acc
ACC2000: How to Use Visual Basic for Applications to Minimize, Maximize,

and
Restore Access


http://support.microsoft.com/default...34&Product=acc
ACC: How to Minimize, Maximize, and Restore MS Access 95/97

At least not in Acc 95 - 2000

--
Regards,
Tom Ogilvy


immanuel wrote in message
...
Try:

accessApp.WindowState = -4137

/i.

"hlam" wrote in message

news:DAwtb.52959$jy.12728@clgrps13...
My excel file is to close itself after access is called, however the
access
file is not opened in full window size. How can I modify the code

in
order
to have the access window in full size?

Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.OpenCurrentDatabase ("D:\db1.mdb")
.Visible = True
End With

Set accessApp = Nothing

ThisWorkbook.Close

End Sub











hlam

Automate Access
 
I added the line as you recommended and now I get an error as :

Run-timer error '2501'
The run command action was cancelled.

"Tom Ogilvy" 级糶秎ン穝籇
...
Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.OpenCurrentDatabase ("D:\db1.mdb")
.Visible = True
.DoCmd.RunCommand acCmdAppMaximize
End With

Set accessApp = Nothing

ThisWorkbook.Close

End Sub
--
Regards,
Tom Ogilvy



hlam wrote in message news:DAwtb.52959$jy.12728@clgrps13...
My excel file is to close itself after access is called, however the

access
file is not opened in full window size. How can I modify the code in

order
to have the access window in full size?








Tom Ogilvy

Automate Access
 
Didn't notice you were using late binding. Replace the acCmdAppMaximize
constant with it numerical value:

? acCmdAppMaximize
10

Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.OpenCurrentDatabase ("D:\db1.mdb")
.Visible = True
.DoCmd.RunCommand 10
End With

Set accessApp = Nothing
ThisWorkbook.Close
End Sub

I tested this modified version of this code to keep the db open

Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application")

With accessApp
.OpenCurrentDatabase ("C:\My Documents\db1.mdb")
.Visible = True
.DoCmd.RunCommand 10
.UserControl = True
End With

' Set accessApp = Nothing
' ThisWorkbook.Close
End Sub


worked fine for me. Access was maximized.

--
Regards,
Tom Ogilvy




hlam wrote in message news:aDCtb.54023$jy.43291@clgrps13...
I added the line as you recommended and now I get an error as :

Run-timer error '2501'
The run command action was cancelled.

"Tom Ogilvy" 级糶秎ン穝籇
...
Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.OpenCurrentDatabase ("D:\db1.mdb")
.Visible = True
.DoCmd.RunCommand acCmdAppMaximize
End With

Set accessApp = Nothing

ThisWorkbook.Close

End Sub
--
Regards,
Tom Ogilvy



hlam wrote in message news:DAwtb.52959$jy.12728@clgrps13...
My excel file is to close itself after access is called, however the

access
file is not opened in full window size. How can I modify the code in

order
to have the access window in full size?










hlam

Automate Access
 
Thanks for your reply. The access window is now opened in full screen. Now
it's about the startup form that was set to Auto Centre and is now
positioned to the left uppen corner. How can I fix this problem?

"Tom Ogilvy" 级糶秎ン穝籇
...
Didn't notice you were using late binding. Replace the acCmdAppMaximize
constant with it numerical value:

? acCmdAppMaximize
10

Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.OpenCurrentDatabase ("D:\db1.mdb")
.Visible = True
.DoCmd.RunCommand 10
End With

Set accessApp = Nothing
ThisWorkbook.Close
End Sub

I tested this modified version of this code to keep the db open

Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application")

With accessApp
.OpenCurrentDatabase ("C:\My Documents\db1.mdb")
.Visible = True
.DoCmd.RunCommand 10
.UserControl = True
End With

' Set accessApp = Nothing
' ThisWorkbook.Close
End Sub


worked fine for me. Access was maximized.

--
Regards,
Tom Ogilvy




hlam wrote in message news:aDCtb.54023$jy.43291@clgrps13...
I added the line as you recommended and now I get an error as :

Run-timer error '2501'
The run command action was cancelled.

"Tom Ogilvy" 级糶秎ン穝籇
...
Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.OpenCurrentDatabase ("D:\db1.mdb")
.Visible = True
.DoCmd.RunCommand acCmdAppMaximize
End With

Set accessApp = Nothing

ThisWorkbook.Close

End Sub
--
Regards,
Tom Ogilvy



hlam wrote in message

news:DAwtb.52959$jy.12728@clgrps13...
My excel file is to close itself after access is called, however the
access
file is not opened in full window size. How can I modify the code

in
order
to have the access window in full size?












Tom Ogilvy

Automate Access
 
Try changing the order of things

Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.Visible = True
.DoCmd.RunCommand 10
.OpenCurrentDatabase ("D:\db1.mdb")
End With

Set accessApp = Nothing
ThisWorkbook.Close
End Sub

I would assume the positioning of the open form is handled by Access, so
maximize it before it makes those decisions.

--
Regards,
Tom Ogilvy

hlam wrote in message news:yFDtb.54204$jy.35975@clgrps13...
Thanks for your reply. The access window is now opened in full screen. Now
it's about the startup form that was set to Auto Centre and is now
positioned to the left uppen corner. How can I fix this problem?

"Tom Ogilvy" 级糶秎ン穝籇
...
Didn't notice you were using late binding. Replace the acCmdAppMaximize
constant with it numerical value:

? acCmdAppMaximize
10

Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.OpenCurrentDatabase ("D:\db1.mdb")
.Visible = True
.DoCmd.RunCommand 10
End With

Set accessApp = Nothing
ThisWorkbook.Close
End Sub

I tested this modified version of this code to keep the db open

Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application")

With accessApp
.OpenCurrentDatabase ("C:\My Documents\db1.mdb")
.Visible = True
.DoCmd.RunCommand 10
.UserControl = True
End With

' Set accessApp = Nothing
' ThisWorkbook.Close
End Sub


worked fine for me. Access was maximized.

--
Regards,
Tom Ogilvy




hlam wrote in message news:aDCtb.54023$jy.43291@clgrps13...
I added the line as you recommended and now I get an error as :

Run-timer error '2501'
The run command action was cancelled.

"Tom Ogilvy" 级糶秎ン穝籇
...
Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.OpenCurrentDatabase ("D:\db1.mdb")
.Visible = True
.DoCmd.RunCommand acCmdAppMaximize
End With

Set accessApp = Nothing

ThisWorkbook.Close

End Sub
--
Regards,
Tom Ogilvy



hlam wrote in message

news:DAwtb.52959$jy.12728@clgrps13...
My excel file is to close itself after access is called, however

the
access
file is not opened in full window size. How can I modify the code

in
order
to have the access window in full size?














hlam

Automate Access
 
That works exactly what I expected. Thank you.

"Tom Ogilvy" 级糶秎ン穝籇
...
Try changing the order of things

Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.Visible = True
.DoCmd.RunCommand 10
.OpenCurrentDatabase ("D:\db1.mdb")
End With

Set accessApp = Nothing
ThisWorkbook.Close
End Sub

I would assume the positioning of the open form is handled by Access, so
maximize it before it makes those decisions.

--
Regards,
Tom Ogilvy

hlam wrote in message news:yFDtb.54204$jy.35975@clgrps13...
Thanks for your reply. The access window is now opened in full screen.

Now
it's about the startup form that was set to Auto Centre and is now
positioned to the left uppen corner. How can I fix this problem?

"Tom Ogilvy" 级糶秎ン穝籇
...
Didn't notice you were using late binding. Replace the

acCmdAppMaximize
constant with it numerical value:

? acCmdAppMaximize
10

Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.OpenCurrentDatabase ("D:\db1.mdb")
.Visible = True
.DoCmd.RunCommand 10
End With

Set accessApp = Nothing
ThisWorkbook.Close
End Sub

I tested this modified version of this code to keep the db open

Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application")

With accessApp
.OpenCurrentDatabase ("C:\My Documents\db1.mdb")
.Visible = True
.DoCmd.RunCommand 10
.UserControl = True
End With

' Set accessApp = Nothing
' ThisWorkbook.Close
End Sub


worked fine for me. Access was maximized.

--
Regards,
Tom Ogilvy




hlam wrote in message

news:aDCtb.54023$jy.43291@clgrps13...
I added the line as you recommended and now I get an error as :

Run-timer error '2501'
The run command action was cancelled.

"Tom Ogilvy" 级糶秎ン穝籇
...
Sub OpenDatabaseFile()

Dim accessApp As Object

Set accessApp = CreateObject("Access.Application.9")

With accessApp
.OpenCurrentDatabase ("D:\db1.mdb")
.Visible = True
.DoCmd.RunCommand acCmdAppMaximize
End With

Set accessApp = Nothing

ThisWorkbook.Close

End Sub
--
Regards,
Tom Ogilvy



hlam wrote in message

news:DAwtb.52959$jy.12728@clgrps13...
My excel file is to close itself after access is called, however

the
access
file is not opened in full window size. How can I modify the

code
in
order
to have the access window in full size?

















All times are GMT +1. The time now is 02:04 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com