Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Update Style in non-active workbook

Hi all,

In a non-active workbook, if I programmatically change the "Normal" style,
returning changed properties are as expected. However if I now make that wb
active nothing has changed. Ie the Normal style is as was.

If I save/reopen that workbook, the Normal style remains as original.
However returning style properties are NOT, reflecting changes I previously
applied. Ie it's no longer possible to confidently return Style properties
in this wb, whether or not active.

I also notice when making changes to the non active workbook, changes are
actually made to the active workbook!!

To demonstrate the problem, I manually set Normal Font Style to Tahoma in
two workbooks. When done I find the active wb has changed but no changes in
what was the non-active wb. Following assumes Book1.xls will be non-active.

Sub ChangeStyle()
Dim sAct1$, sAct2$, sNon1$, sNon2$
Dim wbNon As Workbook

Set wbNon = Workbooks("Book1.xls") 'ensure not active

sAct1 = ActiveWorkbook.Styles("Normal").Font.Name

With wbNon.Styles("Normal").Font
sNon1 = .Name 'returns Active-wb property
.Name = IIf(sNon1 = "Verdana", "Arial", "Verdana")
sNon2 = .Name
End With

sAct2 = ActiveWorkbook.Styles("Normal").Font.Name

Debug.Print sNon1$, sNon2$, wbNon.Name
Debug.Print sAct1$, sAct2$, ActiveWorkbook.Name
Debug.Print

End Sub

How to change Style in non-active workbook without making it active?

TIA, (Excel2000)
Peter T


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
Macro to update active workbook in one folder Mike @ GD Excel Worksheet Functions 8 January 15th 09 02:19 PM
How to change workbook from arabic style to normal VijayDraj Setting up and Configuration of Excel 1 March 27th 08 10:48 PM
Can't find style of workbook Nathan Excel Discussion (Misc queries) 1 January 27th 06 12:00 AM
Update Values as soon as a Worksheet becomes active? CRayF Excel Programming 11 September 28th 05 06:31 AM
update row numbers after different active cells in macros followi. LMIV Excel Discussion (Misc queries) 11 February 16th 05 12:44 AM


All times are GMT +1. The time now is 09:43 AM.

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

About Us

"It's about Microsoft Excel"