ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Workbook_Open() and Object Not Found (https://www.excelbanter.com/excel-programming/366230-workbook_open-object-not-found.html)

FCC[_23_]

Workbook_Open() and Object Not Found
 

Hi,

I am using the Workbook_Open() to open a form that I've built in VBA.
The Sub is very simple:


Code:
--------------------

Private Sub Workbook_Open()
printerSettingsForm.Show
End Sub

--------------------


The only problem is when running this I get the

Run-time error '424'

Object required

And it centers on the sub. I am assuming the problem has to do with
the fact I haven't properly declared or instaniated the object/Form
printerSettingsForm.

I tried goggling, but I couldn't find the proper technique to declare
an object. So I was wondering how I could fix this problem?


--
FCC
------------------------------------------------------------------------
FCC's Profile: http://www.excelforum.com/member.php...o&userid=35888
View this thread: http://www.excelforum.com/showthread...hreadid=558279


Tim Marsh

Workbook_Open() and Object Not Found
 
hi,

try including the following line before the .show line

load printerSettingsForm

hth

tim

"FCC" wrote in message
...

Hi,

I am using the Workbook_Open() to open a form that I've built in VBA.
The Sub is very simple:


Code:
--------------------

Private Sub Workbook_Open()
printerSettingsForm.Show
End Sub

--------------------


The only problem is when running this I get the

Run-time error '424'

Object required

And it centers on the sub. I am assuming the problem has to do with
the fact I haven't properly declared or instaniated the object/Form
printerSettingsForm.

I tried goggling, but I couldn't find the proper technique to declare
an object. So I was wondering how I could fix this problem?


--
FCC
------------------------------------------------------------------------
FCC's Profile:
http://www.excelforum.com/member.php...o&userid=35888
View this thread: http://www.excelforum.com/showthread...hreadid=558279




Leith Ross[_633_]

Workbook_Open() and Object Not Found
 

Hello FCC,

Since you are opening the workbook, Excel doesn't know the user form is
an object in the workbook. Try this method...

With ThisWorkbook
Load .PrinterSettingsForm
..PrinterSetttingsForm.Show
End With

Sincerely,
Leith Ross


--
Leith Ross
------------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...o&userid=18465
View this thread: http://www.excelforum.com/showthread...hreadid=558279


FCC[_26_]

Workbook_Open() and Object Not Found
 

It's funny. I changed the name of my form to userForm and everything
worked fine after that.

It's like Excel doesn't recognize any form objects not named userForm
unless you declare them using the Load button.


--
FCC
------------------------------------------------------------------------
FCC's Profile: http://www.excelforum.com/member.php...o&userid=35888
View this thread: http://www.excelforum.com/showthread...hreadid=558279



All times are GMT +1. The time now is 10:05 AM.

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