Close form automatically upon opening workbook

I

Ixtreme

Hi,

I have a form that is being displayed automatically upon opening the
workbook (I have added the following code in the workbook open event:

Private Sub Workbook_Open()
FrmMain.Show
End Sub

However, I have another workbook that imports information from this
(and many copies of this) workbook). It automatically opens the
workbook, however it halts on the userform that is being displayed. Is
there a possibility that the form is closed with VBA code?

Currently I have:

Path = ActiveWorkbook.Path & "\IMPORT\"
ChDir Path
f = Dir(Path & "*.xls")
While f <> ""

Workbooks.Open f, , , , "PASSWORD"
Unload FrmMain
Sheets("Overview").Activate

The code stops on Unload FrmMain. Is there another way to bypass this?

Mark
 
B

Bernie Deitrick

Mark,

To open a file without running the auto_open macro or the open event, use

Application.EnableEvents = False
Workbooks.Open f, , , , "PASSWORD"
Application.EnableEvents = True

HTH,
Bernie
MS Excel MVP
 
I

Ixtreme

Mark,

To open a file without running the auto_open macro or the open event, use

Application.EnableEvents = False
Workbooks.Open f, , , , "PASSWORD"
Application.EnableEvents = True

HTH,
Bernie
MS Excel MVP














- Tekst uit oorspronkelijk bericht weergeven -

Thanks Bernie!

That is exactly what I needed. Great!

Kind regards,

Mark
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top