在新工作簿中复制Excel主题颜色 [英] Copy Excel theme color in a new workbook
本文介绍了在新工作簿中复制Excel主题颜色的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想创建一个宏,该宏可以在新工作簿中复制两张纸. 但是新创建的工作簿中的主题颜色是不同的.
I want to make a macro that copies two sheets in a new workbook. But the theme color in the new created workbook is different.
Sub Export_File()
Dim Wb3 As Workbook
Dim strSaveName As String
strSaveName = Worksheets("Communication").Range("a2").Value
Set Wb3 = ThisWorkbook
'copy sheets to new workbook
Sheets(Array("Auswertung", "Communication")).Copy
ActiveWorkbook.SaveAs strSaveName
Workbooks(Wb3).Colors = Workbooks(strSaveName).Colors
End Sub
此行不适用于我:
Workbooks(Wb4).Colors = Workbooks(strSaveName).Colors
我认为这与Set Wb4 = ThisWorkbook 需要帮助...
I think it has something to do with Set Wb4 = ThisWorkbook Need help...
问候
推荐答案
这似乎对我有用,可以复制工作簿主题:
This appears to be working for me, to copy a workbook theme:
' copy the colors and themes
'
resultWorkbook.Colors = sourceWorkbook.Colors
'Theme is not the same as colors
Dim sourceTheme As Microsoft.Office.Core.ThemeColorScheme = sourceWorkbook.Theme.ThemeColorScheme
Dim resultTheme As Microsoft.Office.Core.ThemeColorScheme = resultWorkbook.Theme.ThemeColorScheme
For i = 1 To sourceTheme.Count ' there are 12 theme colors: https://msdn.microsoft.com/en-us/library/aa432704(v=office.12).aspx
'Debug.WriteLine(String.Format("{0, -2} ~ {1}", i, sourceTheme.Colors(i).RGB))
resultTheme.Colors(i).RGB = sourceTheme.Colors(i).RGB
Next i
这篇关于在新工作簿中复制Excel主题颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文