LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 80
Default How can I access the "style" definitions in my Add-in?

Thanks for this solution. Here's the code I'll be using - maybe.

Sub testme02()
ActiveWorkbook.Styles.Merge ThisWorkbook
End Sub

I will have to call this macro before the styles are used.
Which is more efficient - Put an if statement checking if the styles are
already merged, or keep executiing testme02?

Sub testme03()
dim sStyle as string

on error resume next
sStyle = ActiveWorkbook.Styles("myStyle").Value
if sStyle="" then
ActiveWorkbook.Styles.Merge ThisWorkbook
end if
on error goto 0
end sub

- Pat


"Dave Peterson" wrote:

Styles live in workbooks, so you'll have to merge your styles from the addin
into the other workbook.

Then you can apply that style to any range in the other workbook.

I created a style in my "sending" workbook/addin named Test1. Then I could use
this code.

Option Explicit
Sub testme01()
Dim FromWkbk As Workbook
Dim ToWkbk As Workbook

Set FromWkbk = Workbooks("myAddin.xla")
Set ToWkbk = Workbooks("book1.xls")

ToWkbk.Styles.Merge Workbook:=FromWkbk

ToWkbk.Worksheets(1).Range("c3").Style = "test1"

End Sub

Dreiding wrote:

I've created an Add-in to add a worksheet based on user inputs from a form.
I use custom style definitions (i.e. Range("A4").Style="myStyle") in my
Add-in.
Unfortunately Excel errors when trying to execute the code.

Is there a way to access the styles defined in the Add-in?

Thanks,
- Pat


--

Dave Peterson
.

 
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
Can I save "Data Text to columns" definitions marg Excel Discussion (Misc queries) 1 December 21st 09 05:44 AM
"Coult not find specified object" and "Path-File access error" messages Robert Crandal Excel Programming 3 December 19th 09 09:12 PM
macro command "definitions" Jim Rech[_2_] Excel Programming 0 February 20th 08 02:47 PM
Problem: Worksheets("New Style 2006").Unprotect Password:="naPrint" Karoo News[_2_] Excel Programming 1 January 30th 06 02:40 PM


All times are GMT +1. The time now is 01:21 AM.

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"