by chijanzen on 十二月 5th, 2009 | View: 1,971 views
Private Sub Workbook_BeforeClose(Cancel As Boolean)On Error Resume NextApplication.CommandBars("Standard").Controls("cmd_TCSC").DeleteApplication.CommandBars("Standard").Controls("cmd_SCTC").DeleteEnd Sub Private Sub Workbook_Open()On Error Resume NextDim TCSCButton As CommandBarButtonApplication.CommandBars("Standard").Controls("cmd_TCSC").DeleteApplication.CommandBars("Standard").Controls("cmd_SCTC").DeleteSet Std_Bar = Application.CommandBars("Standard")Set TCSC_Button = Std_Bar.Controls.Add(Type:=msoControlButton, Temporary:=True)With TCSC_Button .Caption = "cmd_TCSC" .OnAction = "xls_TCSCConverter" ThisWorkbook.Sheets("Sheet2").Shapes("TCSC").Copy .PasteFace .Style = msoButtonIcon .TooltipText = "繁轉簡"End WithSet TCSC_Button = Std_Bar.Controls.Add(Type:=msoControlButton, Temporary:=True)With TCSC_Button .Caption = "cmd_SCTC" .OnAction = "xls_SCTCConverter" ThisWorkbook.Sheets("Sheet2").Shapes("SCTC").Copy .PasteFace .Style = msoButtonIcon .TooltipText = "簡轉繁"End With'清除上面的copy動作Application.CutCopyMode = FalseEnd Sub
Public Declare Function LCMapString Lib "kernel32.dll" Alias "LCMapStringA" _ (ByVal Locale As Long, ByVal dwMapFlags As Long, ByVal lpSrcStr As String, _ ByVal cchSrc As Long, ByVal lpDestStr As String, _ ByVal cchDest As Long) As LongPublic Declare Function LCMapStringA Lib "kernel32.dll" (ByVal Locale As Long, _ ByVal dwMapFlags As Long, ByRef lpSrcStr As Any, _ ByVal cchSrc As Long, ByRef lpDestStr As Any, _ ByVal cchDest As Long) As LongPublic Declare Function LCMapStringW Lib "kernel32.dll" (ByVal Locale As Long, _ ByVal dwMapFlags As Long, ByVal lpSrcStr As Long, _ ByVal cchSrc As Long, ByVal lpDestStr As Long, _ ByVal cchDest As Long) As Long'簡轉繁Public Const LCMAP_SIMPLIFIED_CHINESE As Long = &H2000000Public Const LCMAP_SORTKEY As Long = &H400'繁轉簡Public Const LCMAP_TRADITIONAL_CHINESE As Long = &H4000000Public Const LCMAP_UPPERCASE As Long = &H200
'主語言IDPublic Const LANG_CHINESE As Long = &H4
'次語言IDPublic Const SUBLANG_CHINESE_TRADITIONAL As Long = &H1 '繁Public Const SUBLANG_CHINESE_SIMPLIFIED As Long = &H2 '簡Public Const SUBLANG_CHINESE_HONGKONG As Long = &H3 '港繁
'排序方式Public Const SORT_CHINESE_PRCP As Long = &H0Public Const SORT_CHINESE_BIG5 As Long = &H0Public Const SORT_CHINESE_PRC As Long = &H2
'生成LCIDPublic Const LCID_CHINESE_SIMPLIFIED As Long = ( _ LANG_CHINESE Or SUBLANG_CHINESE_SIMPLIFIED * &H400) _ And &HFFFF& Or SORT_CHINESE_PRCP * &H10000Public Const LCID_CHINESE_TRADITIONAL As Long = ( _ LANG_CHINESE Or SUBLANG_CHINESE_TRADITIONAL * &H400) _ And &HFFFF& Or SORT_CHINESE_BIG5 * &H10000
Sub xls_TCSCConverter() Dim All_Rng As Range Dim crng As Range Dim strData As String TCSCForm.Show 'TCSCForm.IsTCSC_Range If TCSCForm.IsTCSC_Range Then '判斷所選取的是否為儲存格 If TypeName(Selection) = "Range" Then Set All_Rng = Selection Else '取得Sheet中有資料的Range 集合 Set All_Rng = ActiveSheet.Cells.SpecialCells(xlCellTypeConstants, 2) End If End If If TCSCForm.IsTCSC_Sheet Then '取得Sheet中有資料的Range 集合 If Not is_Sheet_Empty Then '工作表是否為空 Set All_Rng = ActiveSheet.Cells.SpecialCells(xlCellTypeConstants, 2) For Each shp In ActiveSheet.Shapes Select Case shp.Type Case msoTextBox, msoFormControl, msoAutoShape shp.DrawingObject.Caption = BIG5ToGB(shp.DrawingObject.Caption) Case msoTextEffect shp.TextEffect.Text = BIG5ToGB(shp.TextEffect.Text) End Select Next Else Exit Sub End If End If '關掉螢幕更新 Application.ScreenUpdating = False For Each crng In All_Rng If Len(crng) > 0 Then '1 繁轉簡 0 簡轉繁 crng = BIG5ToGB(crng.Text) End If Next crng Application.ScreenUpdating = True Unload TCSCFormEnd Sub
If TypeName(Selection) = "Range" Then Set All_Rng = Selection Else '取得Sheet中有資料的Range 集合 Set All_Rng = ActiveSheet.Cells.SpecialCells(xlCellTypeConstants, 2) End If End If '是否轉換整張工作表 If TCSCForm.IsTCSC_Sheet Then If Not is_Sheet_Empty Then '工作表是否為空 '取得Sheet中有資料的Range 集合 Set All_Rng = ActiveSheet.Cells.SpecialCells(xlCellTypeConstants, 2) For Each shp In ActiveSheet.Shapes Select Case shp.Type Case msoTextBox, msoFormControl, msoAutoShape shp.DrawingObject.Caption = GBToBIG5(shp.DrawingObject.Caption) Case msoTextEffect shp.TextEffect.Text = GBToBIG5(shp.TextEffect.Text) End Select Next Else Exit Sub End If End If '關掉螢幕更新 Application.ScreenUpdating = False For Each crng In All_Rng If Len(crng) > 0 Then '1 繁轉簡 0 簡轉繁 crng = GBToBIG5(crng.Text) End If Next crng Application.ScreenUpdating = True Unload TCSCFormEnd Sub
BIG5ToGB = szDestEnd Function
Dim pIsTCSC_Range As BooleanDim pIsTCSC_Sheet As Boolean Private Sub TDSC_Cmd_Click()If Me.OptTCSC_Range Then pIsTCSC_Range = TrueElse pIsTCSC_Range = faleEnd IfIf Me.OptTCSC_Sheet Then pIsTCSC_Sheet = TrueElse pIsTCSC_Sheet = FalseEnd IfMe.HideEnd Sub Private Sub UserForm_Initialize()'預設為整張工作表Me.OptTCSC_Sheet = TrueEnd Sub Public Property Get IsTCSC_Range() As BooleanIsTCSC_Range = pIsTCSC_RangeEnd Property Public Property Get IsTCSC_Sheet() As BooleanIsTCSC_Sheet = pIsTCSC_SheetEnd Property Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)Cancel = TrueEnd Sub
檔案請解壓縮到同一資料夾中,請執行 InstallAddin.xls 檔案安裝增益集
VBE密碼:1234
Popularity: 31%
為什麼我用不到這個好東西...天呀????? 我的是64BIT Win7, office 2007 .... HELP ! ...
Name: « Required
Email Address: « Required
Website URL: « Optional
Type your message here...
You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
發表於討論區 一般訪客留言 於 九月 7, 2010
發表於討論區 一般訪客留言 於 六月 6, 2010
發表於討論區 API函數 於 一月 19, 2010
發表於討論區 技術交流 於 一月 13, 2010
發表於討論區 一般訪客留言 by reader 於 九月 7, 2010 at 9:31 下午
發表於討論區 一般訪客留言 by kenjo 於 六月 6, 2010 at 2:55 下午
發表於討論區 API函數 by chijanzen 於 一月 19, 2010 at 1:50 下午
發表於討論區 API函數 by chijanzen 於 一月 19, 2010 at 1:11 下午
發表於討論區 技術交流 by chijanzen 於 一月 13, 2010 at 5:43 下午
GEOLOC
姓名:超級皮卡丘
網路化名: chijanzen、中國龍
經歷:
為什麼我用不到這個好東西...天呀????? 我的是64BIT Win7, office 2007 .... HELP ! ...