Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default UnMerge Opened Workbook from Add-In

Sample addin sent.
--
Regards,
Tom Ogilvy

"scott" wrote in message
...
I read Chip's page on "Application Events" and still have an issue. I did
exactly like his download example except I'm forced to put below code in a
class module that resides in my add-in (which is always loaded).

His example works because the class module resides in a workbook. My

problem
is my class module doesn't fire because it's in my add-in, not a workbook.

I
can't put it in the workbook because it is being sent automatically from a
machine.

Is it possible to fire an event on open event in an add-in?


Private Sub App_WorkbookOpen(ByVal Wb As Excel.Workbook)

MsgBox "Application Event: WorkbookOpen: " & Wb.Name
Call UnMerge

End Sub


"Tom Ogilvy" wrote in message
...
If I understand what you want to do, you would need to instantiate
application level events. Using the application level workbook_open
equivalent, you would then be able to react to each workbook as it is
opened. The workbook_Open event of your addin only fires when the addin
is
first opened - thus your problem.

for each sh in Activeworkbook.Worksheets
sh.Cells.Unmerge
Next

would work for me to unmerge all cells - I don't know what that code is
you
have, but maybe you recorded it that way.

http://www.cpearson.com/excel/appevent.htm
Chip Pearson's page on application level events.

--
Regards,
Tom Ogilvy


"scott" wrote in message
...
Below is a sub I have that unmerges any cells in the workbook. My

problem
is
that I now need this sub to exist in an add-in and run on any opened
worksheet (I'd prefer it to test if merged cells exist 1st, but not a
requirement). Ideally, it would iterate through all opened workbooks

and
run
on any sheets.

Given the fact that I'm not going to know the name of the workbook that

will
have the merged cells and that I will be performing actions on from the

sub
functions contained in the add-in, how can I force the below add-in sub
to
unmerge cells on the opened workbook? Right now it gives an error when
run
from Auto_Open() sub in the add-in. Error is "method cells of object

_global
failed"


Sub UnMerge()

Cells.Select
With Selection
.VerticalAlignment = xlTop
.WrapText = False
.Orientation = 0
.AddIndent = False
.ShrinkToFit = False
.ReadingOrder = xlContext
.MergeCells = False
End With

End Sub








Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening a workbook if not opened, going to it if already opened neotokyo[_3_] Excel Programming 0 September 24th 04 08:56 PM
Opening a workbook if not opened, going to it if already opened neotokyo[_2_] Excel Programming 1 September 24th 04 07:17 PM
Opening a workbook if not opened, going to it if already opened neotokyo Excel Programming 1 September 24th 04 06:33 PM
How to see if the opened workbook is opened by another user ? balexis Excel Programming 1 August 18th 04 04:11 PM
Sheets select method fails when workbook is opened by another workbook Mike Excel Programming 2 June 8th 04 04:17 AM


All times are GMT +1. The time now is 08:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"