Hiding Columns before Saving

A

Aidy

I'm tring to hide a column before I save the workbook. So I'm using
the 'WorkbookBeforeSave' event method.

I've put this in the class module

Public WithEvents App As Application

Public Sub App_WorkbookBeforeSave(ActiveWorkbook, _
ByVal SaveAsUI As Boolean, Cancel As Boolean)

Columns("D:D").Select
Selection.EntireColumn.Hidden = True

End Sub

And this in a normal module

Public Ev As ClsEvents

Sub SaveAndHideCols()

Set Ev = New ClsEvents

Ev.App_WorkbookBeforeSave ActiveWorkbook, False, False

End Sub


However, when I press save, the code within the event method is not
activated.

What am I doing wrong?

Cheers

Aidy
 
F

Frank Kabel

Hi
why don't you put your code in the workbook module and use the
pre-defined event Workbook_BeforeSave
 

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