You can export the chart to your desired location through following code:
Sub exportChart()
Dim cht as chart
Set Cht = Worksheets("Charts").ChartObjects(1).Chart Cht.Export Filename:="C:\Temp\MyChart.gif", FilterName:="GIF"
End Sub
---------------------
I use this code to export chart and load them as image in Userform which looks pretty good for presentation.
Ads by Google
Showing posts with label VBA. Show all posts
Showing posts with label VBA. Show all posts
Friday, May 15, 2009
Sunday, August 3, 2008
When I open a workbook it prompts me to enable macros; although there are no macros in the file. Why?
Whenever Macros are recorded in a workbook, Modules get created. These modules house the VBA Codes. So whenever Excel detects any module in a workbook it prompts you to enable macros even though there might not be any macros in he file.
Example: Sometimes we try our hand on Macros and then later delete these macros. Even though there are no Macros, Excel gives an Enable Macros prompt on opening the file because the file still houses the Module(s) (including Class Module(s) if any) which have not been removed. So if you are wondering why this popup when there are no macros? All you have to do is go to the VBA Screen (Alt+F11) right click the Module(s) and delete them; this will get rid of the Enable Macros prompt.
Note : Some people get the impression that this popup appears for macros have been used on the workbook in past. However this is not true as running macros from personal.xls or an addin or any other file will neither create VBA code (in sheets or modules) nor will it create new modules. Hence mere running of macros ona file will not result in ‘Enable Macros prompt’ when you open them.
Example: Sometimes we try our hand on Macros and then later delete these macros. Even though there are no Macros, Excel gives an Enable Macros prompt on opening the file because the file still houses the Module(s) (including Class Module(s) if any) which have not been removed. So if you are wondering why this popup when there are no macros? All you have to do is go to the VBA Screen (Alt+F11) right click the Module(s) and delete them; this will get rid of the Enable Macros prompt.
Note : Some people get the impression that this popup appears for macros have been used on the workbook in past. However this is not true as running macros from personal.xls or an addin or any other file will neither create VBA code (in sheets or modules) nor will it create new modules. Hence mere running of macros ona file will not result in ‘Enable Macros prompt’ when you open them.
Tuesday, July 29, 2008
Unhide all sheets thro Macro
You would have noticed that we cannot select all the worksheets from the Unhide options. This becomes tougher when we have unhide multiple sheets. We have to choose each sheet and then unhide them. Easiest way to unhide all the sheets is to use following VBA code:
'-------VBA Code---------------
Sub Unhide()
'Unhide all sheets macro by Saalim
Dim wkst As Worksheet
For Each wkst In Worksheets
wkst.Visible = xlSheetVisible
Next wkst
End Sub
'------------Code End----------------
This way we can save a lot of time on manually unhiding the sheets.
-Saalim
'-------VBA Code---------------
Sub Unhide()
'Unhide all sheets macro by Saalim
Dim wkst As Worksheet
For Each wkst In Worksheets
wkst.Visible = xlSheetVisible
Next wkst
End Sub
'------------Code End----------------
This way we can save a lot of time on manually unhiding the sheets.
-Saalim
Subscribe to:
Posts (Atom)