Microsoft Excel Question:

Download Job Interview Questions and Answers PDF

How can I save a chart as a GIF file?

MS Excel Interview Question
MS Excel Interview Question

Answer:

You can save your worksheet as an HTML file, and Excel will automatically convert any charts to GIF files.

If that seems like overkill, you can write a simple macro that will do the job. Press Alt-F11 to activate the Visual Basic editor. Select your workbook in the Projects window, and choose Insert, Module to insert a new VBA module. Then type the following four-line procedure into the module:

Sub SaveChartAsGIF ()

Fname = ThisWorkbook.Path & "" & ActiveChart.Name & ".gif"

ActiveChart.Export FileName:=Fname, FilterName:="GIF"

End Sub

After the macro is entered, reactivate Excel and click the chart to be saved. Press Alt-F8 to display the Macro dialog box. Select the SaveChartAsGIF macro and click Run. The procedure uses the chart's name as the GIF file name, and the file is stored in the same directory as the workbook.

This simple macro does no error checking, so it will generate an error if a chart is not selected or if the workbook has not been saved.

Download MS Excel Interview Questions And Answers PDF

Previous QuestionNext Question
All of a sudden, when I open the file, it asks if I want to "Enable or Disable a Macro". There are no macros in this workbook?How can I print a workbooks full path in the header or footer? The Page Setup dialog box does not seem to offer the option.?