高手請進:如何用vb實現Excel菜單/工具欄修改,及保存
就是,整個過程都用vb實現。
不用手動去設置excel
然後在下次打開excel 程序時,修改的菜單/工具欄可以實現保存
以下代碼,當我打開設置excel後,手動關閉excel 就可以修改的菜單/工具欄可以實現保存。但是如果用vb 的quit 和 set = nothing 就沒有辦法保存設置!
請高手幫忙看看!什麼問題 謝謝!
Public Function ExcelDefault()
'Exit Function
Dim ExcelApp2 As Object
Dim myxls2 As Object
Set ExcelApp2 = CreateObject( "Excel.application ")
ExcelApp2.Visible = True
Set myxls2 = ExcelApp2.Workbooks.Add()
'恢復Excel默認
ExcelApp2.CommandBars(1).Enabled = True
ExcelApp2.CommandBars( "Cell ").Enabled = True
ExcelApp2.CommandBars( "Formatting ").Enabled = True
ExcelApp2.CommandBars( "Standard ").Enabled = True
ExcelApp2.CommandBars(1).Visible = True
ExcelApp2.CommandBars( "Formatting ").Visible = True
ExcelApp2.CommandBars( "Standard ").Visible = True
ExcelApp2.WindowState = 1
‘以下代碼實現自動關閉,打開的excel 但是設置就不能保存。如果屏蔽下面代碼,然後手動關閉excel 就能保存設置
' MsgBox "Reback Excel Setting! ", , "Attention: "
' ExcelApp2.DisplayAlerts = False '退出不提示保存
' ExcelApp2.Save
' ExcelApp2.quit
' Set ExcelApp2 = Nothing
' Set myxls2 = Nothing
End Function
[解决办法]
机器上没有EXCEL,光一个破WORD,呵呵..WORD2003测试以上代码通过...VBA原始宏代码是:
Application.Quit (True)
[解决办法]
saveas
记得好像是这样,你试试