How to Export Excel Data to Text Files in Excel

This post will explain how to export Excel data to text files in Excel using VBA code. This post will show you how to export one sheet to text files in Excel, which can be useful if you need to extract data from Excel and use it in another program that requires a text file format.

You can easily select the data you want to export, specify a file name and location for the text file, and then generate a text file that contains the data in the format you need.

Export one Single Worksheet to Text File

If you want to export a single Excel sheet to a text file, follow these steps:

Step1: Open the Excel workbook that contains the sheet you want to export.

Step2: Click on the sheet you want to export.

Step3: Click on the “File” tab in the ribbon menu.

Step4: Click on “Save As” in the left-hand menu.

Step5: In the “Save As” dialog box, choose the location where you want to save the text file.

Step6: In the “Save as type” dropdown menu, select “Text (Tab delimited) (*.txt)“.

How to Export Excel Data to Text Files in Excel1.png

Step7: Click on the “Save” button.

Export one Column or Selection to Text File with VBA Code

You can use VBA code to export a selection or one column to a text file in Excel. Here are the steps:

Step1: Press “Alt + F11” on your keyboard. This will open the Visual Basic Editor window.

Step2: In the Visual Basic Editor window, select “Insert” from the top menu and choose “Module” to create a new module.

Step3: Copy and paste the following VBA code into the new module. Save the workbook with the VBA code.

Sub ExportSelectionToTextFile_ExcelHow()
    Dim myFile As String
    Dim rng As Range
    
    'Get the range to be exported from the user
    On Error Resume Next
    Set rng = Application.InputBox("Please select the range to be exported:", Type:=8)
    On Error GoTo 0
    
    'If no range is selected, exit the sub
    If rng Is Nothing Then Exit Sub
    
    'Create a new workbook and copy the selected range to it
    Dim wb As Workbook
    Set wb = Workbooks.Add
    rng.Copy Destination:=wb.Sheets(1).Range("A1")
    
    'Get the file name and location for the text file
    myFile = Application.GetSaveAsFilename(InitialFileName:="ExportedData.txt", FileFilter:="Text Files (*.txt), *.txt")
    
    'If the user cancels the file selection, exit the sub
    If myFile = "False" Then Exit Sub
    
    'If the file name is not valid, display an error message and exit the sub
    If Len(myFile) = 0 Then
        MsgBox "Invalid file name. Please select a valid file name and location.", vbExclamation, "Export to Text File"
        Exit Sub
    End If
    
    'Save the new workbook as a text file and close it
    wb.SaveAs FileName:=myFile, FileFormat:=xlText, CreateBackup:=False
    wb.Close SaveChanges:=False
    
    'Display a success message
    MsgBox "Data has been exported to text file successfully!", vbInformation, "Export to Text File"
End Sub

Step4: Press “Alt + F8” to open the Macro dialog box. Select the ” ExportSelectionToTextFile_ExcelHow” macro from the list of macros and click “Run“.

How to Export Excel Data to Text Files in Excel vba 2.png

Step5: select the range to be exported

How to Export Excel Data to Text Files in Excel vba 3.png

Step6: select a file name and location for the text file to be exported.

How to Export Excel Data to Text Files in Excel vba 4.png

Step6: Click “Save” to export the selected range to the text file.

How to Export Excel Data to Text Files in Excel vba 5.png

The selected range should now be exported to a text file in the location that you specified.

Video: Export Excel Data to Text Files This

This video will demonstrate how to export Excel data to text files in Excel using VBA Code.

How to Export a Range of Data to HTML or Web Page File in Excel

This post will explain how to export a range of data from an Excel worksheet to an HTML or web page file using the Save As command and VBA code. This method allows you to create a standalone HTML file that can be opened in any web browser, making it easy to share your data with others.

Export a Range of Data to HTML or Web Page File with Save As Command

If you want to export a range of data from Excel to HTML or web page file, one common method is to use the “Save As” function in Excel.

Here are the steps:

Step1: Select the range of data you want to export to HTML. You can select the cells by clicking and dragging the cursor over the cells.

How to export a range of data to HTML or web page file in Excel 1.png

Step2: Click on the “File” tab in the Excel ribbon. Click on “Save As“.

How to export a range of data to HTML or web page file in Excel 2.png

Step3: In the “Save As” dialog box, choose “Web Page” from the file type dropdown menu. Choose the location where you want to save the file and give it a name. Click on “Publish” button.

How to export a range of data to HTML or web page file in Excel 3.png

Step4: In the “Publish Options” section, select the “Selection” option to export only the selected range of cells. click Save button.

How to export a range of data to HTML or web page file in Excel 4.png

Step5: the Publish as Web Page dialog box will open, Click on the “Publish” button to export the range of data to an HTML file.

How to export a range of data to HTML or web page file in Excel 5.png

Step6: After completing these steps, the selected range of data will be exported to an HTML file that can be opened in a web browser.

Export a Range of Data to HTML or Web Page File with VBA Code

You can also export a range of data to an HTML file with VBA Code in Excel, and you can use the Application.InputBox function to select the range of data to export and prompt the user to select the destination directory and filename. Just do the following steps:

Step1: Press ALT + F11 on your keyboard to open the Visual Basic Editor (VBE).

Step2: In the VBE, click on the Insert menu and select Module. This will create a new module in your VBA project.

Step3: Copy the below VBA code and paste it into the module. Save your VBA project and close the VBE.

Sub ExportRangeToHTML_Excelgeek()

    Dim wb As Workbook
    Dim ws As Worksheet
    Dim rng As Range
    Dim htmlFile As String
    
    Set wb = ThisWorkbook
    Set ws = wb.ActiveSheet
     ' Prompt the user to select the range of data to export
    Set rng = Application.InputBox(prompt:="Select the range of data to export as HTML", Type:=8)
    
    ' Prompt the user to select the destination directory and filename
    htmlFile = Application.GetSaveAsFilename(fileFilter:="HTML Files (*.html), *.html")
    
    'Create a new workbook with the selected range of data and save it as an HTML file
    Dim newWb As Workbook
    Set newWb = Workbooks.Add
    rng.Copy
    newWb.Sheets(1).Range("A1").PasteSpecial xlPasteAll
    newWb.SaveAs htmlFile, xlHtml
    newWb.Close
    
    MsgBox "Selected range has been exported to " & htmlFile

End Sub

Step4: Press ALT + F8 on your keyboard to open the Macro dialog box. Select the ExportRangeToHTML_Excelgeek macro from the list and click the Run button.

vba to export a range of data to HTML or web page file in Excel 2.png

Step5: select the range of data to export in your current worksheet.

vba to export a range of data to HTML or web page file in Excel 3.png

Step6: choose a location to save the HTML file.

vba to export a range of data to HTML or web page file in Excel 4.png

Step7: Once the macro has completed, a message box will appear indicating that the selected range has been exported to the chosen location.

vba to export a range of data to HTML or web page file in Excel 5.png

You should now have an HTML file containing the data from the selected range.

Conclusion

Now you can quickly and easily export a range of data to an HTML file without having to manually copy and paste the data into a web page editor.

How to Copy a Selected Range to New Workbook in Excel

If you work with large amounts of data in Excel, it is likely that you have needed to copy a selected range of cells to a new workbook at some point. While you can manually copy and paste the range, this process can be time-consuming and error-prone, especially if you need to repeat the task frequently.

Fortunately, there are several ways to automate the process of copying a selected range to a new workbook in Excel. In this post, we will introduce two methods to achieve this task – the first one is the manual method, and the second one is using VBA code with Application.InputBox to select the range.

Copy a Selected Range to a New Workbook Manually

If you want to copy a selected range to a new workbook manually in Excel , you can follow these steps:

Step1: Select the range of cells you want to copy.

How to copy a selected range to a new workbook in Excel1.png

Step2: Press Ctrl + C on your keyboard to copy the selected range.

Step3: Click on the File tab in the ribbon menu, then select New to create a new workbook.

Step4: In the new workbook, click on the first cell where you want to paste the copied range.

How to copy a selected range to a new workbook in Excel2.png

Step5: Press Ctrl + V on your keyboard to paste the copied range.

Copy a Selected Range to a New Workbook with VBA Code

You can also use the VBA Code to copy a selected range to a new workbook in Excel, it will use the Application.Inputbox function to select the range. Just do the below steps:

Step1: Open the Excel workbook that contains the range you want to copy.

Step2: Press Alt + F11 on your keyboard to open the Visual Basic Editor.

Step3: In the Visual Basic Editor, click on Insert from the top menu and select Module to insert a new module.

Step4: Copy and paste the VBA code provided in the module.

vba to copy a selected range to a new workbook in Excel1.png
Sub CopyRangeToNewWorkbook_excelgeek()
    Dim myRange As Range
    Dim newWorkbook As Workbook
    
    'Prompt user to select range to copy
    Set myRange = Application.InputBox(prompt:="Select the range to copy", Type:=8)
    
    'Create a new workbook
    Set newWorkbook = Workbooks.Add
    
    'Copy the selected range to the new workbook
    myRange.Copy Destination:=newWorkbook.Sheets(1).Range("A1")
    
    'Activate the new workbook
    newWorkbook.Activate
End Sub

Step5: Press F5 or Run from the top menu to run the macro.

vba to copy a selected range to a new workbook in Excel2.png

Step6: In the pop-up window, select the range you want to copy by clicking and dragging your mouse over the cells. Click on the OK button to start the macro.

vba to copy a selected range to a new workbook in Excel3.png

Step7: Excel will create a new workbook and copy the selected range to the new workbook.

vba to copy a selected range to a new workbook in Excel4.png

How to Save an Excel Table as Image in Excel

This tutorial will introduce three methods for saving an Excel table as an image in Excel: “Paste as picture”, “Paint tool”, and “VBA code“.

The Paste as picture method allows you to create a picture of a range that can be easily inserted into documents or presentations.

The Paint tool method uses the built-in Windows Paint program to save the selected range as an image.

The VBA code method automates the process of saving the selected range as an image using Visual Basic for Applications (VBA) code.

Save Table as Image using Paste as Picture

You can save an Excel table as an image using the “paste as picture” feature. Here are the steps:

Step1: Select the table that you want to save as an image.

How to Save an Excel Table as Image in Excel 1.png

Step2: Right-click on the selected cells and choose “Copy” from the context menu or press Ctrl+C on your keyboard.

How to Save an Excel Table as Image in Excel 2.png

Step3: select one destination cell to place the image.  Then click the Home tab, click on the drop-down menu list from the Paste option in the Clipboard group.  Click on the Picture option.

How to Save an Excel Table as Image in Excel3.png

Now you can simply copy the image and paste it to other application.

Save Table as Image using Paint Tool

You can save an Excel table as an image using the Paint tool in Windows. Here are the steps:

Step1: Select the table that you want to save as an image.

Step2: Right-click on the selected cells and choose “Copy” from the context menu or press Ctrl+C on your keyboard.

Step3: Open the Paint tool by typing “Paint” in the Windows search bar and selecting the app from the search results.

Step4: In Paint, choose “Paste” from the “Home” tab or press Ctrl+V on your keyboard to paste the copied table into the canvas.

How to Save an Excel Table as Image in Excel4.png

Step5: Choose “Save As” from the “File” menu and select the desired file format (e.g. JPEG, PNG, BMP, etc.).

How to Save an Excel Table as Image in Excel5.png

Step6: Enter a file name and choose a save location. Click “Save” to save the image.

How to Save an Excel Table as Image in Excel6.png

Save Table as Image with VBA Code in Excel

You can use VBA code in Excel to save a selected table as an image and prompt the user to select a destination to save the image. Just do the following steps:

Step1: Open your Excel workbook.

Step2: Press Alt + F11 to open the VBA editor.

Step3: In the VBA editor, select Insert from the menu bar, then choose Module to create a new module.

Step4: Copy the VBA code I provided and paste it into the new module. Save the workbook and close the VBA editor.

vba to Save an Excel Table as Image in Excel 1.png
Sub sleep(T As Single)
    Dim time1 As Single
    time1 = Timer
    Do
        DoEvents
    Loop While Timer - time1 < T
End Sub
Sub SaveTableAsImage_excelgeek()
    Dim tbl As Range
    Dim savePath As String, fileName As String, fileFormat As String
    Dim cht As ChartObject
      
    'Prompt the user to select the table to save as an image
    Set tbl = Application.InputBox("Select the table to save as an image:", Type:=8)

    tbl.CopyPicture xlScreen, xlPicture
 
     'prompt user for save location and file name
    savePath = Application.GetSaveAsFilename(InitialFileName:="table1", _
        FileFilter:="JPEG (*.jpg), *.jpg, PNG (*.png), *.png")
    If savePath = "False" Then Exit Sub ' exit if user clicks cancel
     
    'extract file name and format from save path
    fileName = Mid(savePath, InStrRev(savePath, "\") + 1)
    fileFormat = Mid(fileName, InStrRev(fileName, ".") + 1)
    fileName = Left(fileName, InStrRev(fileName, ".") - 1)
    
    
    'create temporary chart object, set dimensions to table dimensions, paste table inside, and save as image
    Set cht = ActiveSheet.ChartObjects.Add(0, 0, tbl.Width, tbl.Height)
    Call sleep(2)
    cht.Chart.Paste
    cht.Chart.Export savePath, fileFormat
    cht.Delete
    Application.CutCopyMode = False
    
End Sub

Step5: Press Alt + F8 to open the Macros dialog box. Select the SaveTableAsImage_excelgeek macro from the list and click the Run button.

vba to Save an Excel Table as Image in Excel 2.png

Step6: Select the table to save as an image.

vba to Save an Excel Table as Image in Excel 3.png

Step7: select one the location to place image.

vba to Save an Excel Table as Image in Excel 4.png

Step8: The picture will be saved into the selected location.

vba to Save an Excel Table as Image in Excel 5.png

Conclusion

There are several methods available for saving an Excel table as an image, each with its own advantages and limitations. The “Paste as picture” method is quick and easy, but may result in lower image quality. The “Paint tool” method provides greater control over image quality, but requires an extra step. The “VBA code” method offers the most automation and customization options, but may require some programming knowledge.

How to Copy and Paste Range or Chart object as Picture in Excel

This post will introduce two methods to copy and paste a range or chart object as a picture in Excel. The first method involves using Excel’s built-in “Copy as Picture” feature, while the second method uses VBA code to automate the process.

The VBA code method will select a range or chart object using Application.Inputbox function and choose a destination cell for the picture. The VBA code will then copy the range or chart object as a picture and paste it into the specified cell.

Copy and Paste Range or Chart object as Picture using Copy as Picture

You can use the “Copy as Picture” feature in Excel to copy a range or chart object as a picture. Here are the steps:

Step1: Select the range or chart object that you want to copy as a picture.

How to Copy and Paste Range or Chart object as Picture in Excel 1.png

Step2: Go to the “Home” tab in the Excel Ribbon. Click the drop-down arrow next to the “Copy” button in the “Clipboard” section. Select “Copy as Picture” from the drop-down menu. The Copy Picture dialog box will open.

How to Copy and Paste Range or Chart object as Picture in Excel 2.png

Step3: In the “Copy Picture” dialog box, select the Format as Picture, and select Appearance as shown on screen.

How to Copy and Paste Range or Chart object as Picture in Excel 3.png

Step4: Click the “OK” button to copy the range or chart object as a picture.You can paste the picture wherever you want by pressing “Ctrl + V” on the keyboard.

How to Copy and Paste Range or Chart object as Picture in Excel 4.png

Copy and Paste Range or Chart object as Picture with VBA Code

You can also use the VBA Code to copy a range or chart object and paste it in your Excel worksheet, just do the following steps:

Step1: Open your Excel workbook.

Step2: Press Alt + F11 to open the VBA editor.

Step3: In the VBA editor, select Insert from the menu bar, then choose Module to create a new module.

Step4: Copy the VBA code I provided and paste it into the new module. Save the workbook and close the VBA editor.

vba Copy and Paste Range or Chart object as Picture in Excel 12.png
Sub CopyAsPicture_excelgeek()
    Dim rng As Range
    Dim chartObj As ChartObject
    Dim destCell As Range
    
    'Prompt user to select range or chart object
    On Error Resume Next
    Set rng = Application.InputBox("Select a range or chart object to copy as picture", Type:=8)
    On Error GoTo 0
    
    'If user selects a range, copy it as picture
    If Not rng Is Nothing Then
        rng.CopyPicture xlScreen, xlPicture
        
        'Prompt user to select destination cell
        On Error Resume Next
        Set destCell = Application.InputBox("Select destination cell to place picture", Type:=8)
        On Error GoTo 0
        
        'If user selects a cell, paste the picture and adjust its size
        If Not destCell Is Nothing Then
            With destCell.Parent.Pictures.Paste
                .Left = destCell.Left
                .Top = destCell.Top
                .Width = rng.Width
                .Height = rng.Height
            End With
        End If
    'If user selects a chart object, copy it as picture
    ElseIf ActiveChart Is Nothing Then
        MsgBox "Please select a range or chart object."
    Else
        Set chartObj = ActiveSheet.ChartObjects(ActiveChart.Parent.Name)
        chartObj.Chart.Export Environ$("temp") & "\temp.png", "PNG"
        With destCell.Parent.Pictures.Insert(Environ$("temp") & "\temp.png")
            .Left = destCell.Left
            .Top = destCell.Top
            .Width = chartObj.Width
            .Height = chartObj.Height
        End With
        Kill Environ$("temp") & "\temp.png"
    End If
End Sub

Step5: Press Alt + F8 to open the Macros dialog box. Select the CopyAsPicture_excelhow macro from the list and click the Run button.

vba Copy and Paste Range or Chart object as Picture in Excel 13.png

Step6: Select the cell where you want to paste the picture.

vba Copy and Paste Range or Chart object as Picture in Excel 3.png

Step7: select one the destination cell to place picture.

Step8: The picture will be pasted into the selected cell.

vba Copy and Paste Range or Chart object as Picture in Excel 5.png

How to Convert Range to Image in Excel

This post will introduce you to two methods of converting a range of cells to an image in Excel. The method involves using the “Copy As Picture” feature in Excel and a VBA code to export the copied range as an image file.

Convert Cells Range to Image Using Copy as Picture Feature

If you want to convert a range of cells to an image in Microsoft Excel Spreadsheet, you can use the built-in “Copy As Picture” feature. Here are the steps:

Step1: Select the cells range that you want to convert to an image.

Step2: Press the “Ctrl + C” shortcut on your keyboard to copy the cells range to the clipboard.

How to convert cells range to image in Excel 1.png

Step3: Click on the “Home” tab in the ribbon. Click on the “Copy” dropdown arrow in the “Clipboard” group, and then select “Copy as Picture“. The Copy Picture dialog box will open.

How to convert cells range to image in Excel 2.png

Step4: In the “Copy Picture” dialog box, select the “As shown on screen” option and the “Picture” format. Click on the “OK” button.

How to convert cells range to image in Excel 3.png

Step5: Now you can paste the copied cells range as an image in another location. For example, you can open an image editor (such as Microsoft Paint), and press the “Ctrl” and “V” keys on your keyboard to paste the image.

How to convert cells range to image in Excel4.png

Convert Cells Range to Image with VBA Code

You can also use VBA code to automate the process of converting a range of cells to an image. Just do the following steps:

Step1: Open your workbook that contains the range of cells you want to convert to an image.

Step2: Press Alt + F11 to open the Visual Basic Editor.

Step3: In the Visual Basic Editor, click on Insert > Module to create a new module.

Step4: Copy the below VBA code and paste it into the new module.

vba to convert cells range to image in Excel 1.png
Sub ConvertRangeToImage_excelgeek()
    Dim MyChart As ChartObject
    Dim MyRange As Range
    Dim DestPath As String
    Dim FileName As String
    
    Set MyRange = Application.InputBox("Select the range of cells:", Type:=8)
    MyRange.CopyPicture xlScreen, xlPicture
    
    Set MyChart = ActiveSheet.ChartObjects.Add(0, 0, MyRange.Width, MyRange.Height)
    
    MyChart.Activate
    MyChart.Chart.Paste
    DestPath = Application.GetSaveAsFilename(InitialFileName:="MyImage", _
        FileFilter:="PNG Files (*.png), *.png, JPEG Files (*.jpg), *.jpg, GIF Files (*.gif), *.gif, BMP Files (*.bmp), *.bmp", _
        Title:="Save As")
    If DestPath <> "False" Then
        FileName = Mid(DestPath, InStrRev(DestPath, "\") + 1)
        MyChart.Chart.Export DestPath, Mid(DestPath, InStrRev(DestPath, ".") + 1)
    End If
    MyChart.Delete
End Sub

Step5: Save the module and close the Visual Basic Editor. Press Alt + F8 to open the Macro dialog box.Select the ConvertRangeToImage_excelgeek macro from the list of available macros and click Run.

vba to convert cells range to image in Excel 2.png

Step6: select the range of cells you want to convert to an image.

vba to convert cells range to image in Excel 3.png

Step7: The code will prompt you to choose the destination folder and image name for the converted image.

vba to convert cells range to image in Excel 4.png

Step8: Once you select the destination folder and image name, the code will export the range of cells as an image file in the selected format.

vba to convert cells range to image in Excel 5.png

Conclusion

 With the above methods, you can easily convert any range of cells in your Excel worksheet to a PNG, JPG or other image format, which can be useful for sharing data, creating reports, or including the data in a presentation.

How to Save charts as GIF images in Excel

This post will introduce how to save charts as GIF images in Excel. We will cover different methods to save Excel charts as GIF images, including using Excel’s built-in functionality, third-party tools, and VBA code.

Save charts as GIF images Using Save As Picture Feature in Excel 365

To save charts as GIF images in Excel, you can use the following steps:

Step1: Select the chart that you want to save as a GIF image.

Step2: Right-click on the chart and select “Save as Picture” from the context menu.

Step3: In the “Save as Picture” dialog box, select “GIF” as the file type.

How to Save charts as GIF images in Excel2.png

Step4: Choose a file name and location for the GIF image, and click “Save“.

Save charts as GIF images with Paint

You can use paint tool to save charts as GIF images in Excel, you can use the following steps:

Step1: Select one chart that you want to save it as a GIF image.

Step2: Press the “Print Screen” button on your keyboard to capture a screenshot of the chart or just press Ctrl +C to copy the selected chart.

How to Save charts as GIF images in Excel3.png

Step3: Open Paint tool, typing “Paint” in the search box, and selecting “Paint” from the list of results. Press “Ctrl + V” on your keyboard to paste the screenshot into Paint.

How to Save charts as GIF images in Excel4.png

Step4: Click “File” in the top left corner of the Paint window, select “Save as“, and choose “GIF picture” as the file type.

How to Save charts as GIF images in Excel5.png

Step5: Choose a file name and location for the GIF image, and click “Save“.

Save charts as GIF images Using Word

To save charts as GIF images using Word, you can do the following steps:

Step1: Copy the chart that you want to save as a GIF image in Excel.

Step2: Open Word by clicking the “Start” button, typing “Word” in the search box, and selecting “Word” from the list of results.

Step3: Click where you want to insert the chart in your Word document. Click on Home->Paste->Paste Special.  Then select Picture (GIF) in the Paste Special dialog box.

How to Save charts as GIF images in Excel8.png

Step4: Right-click on the chart and select “Save as Picture” from the context menu.

How to Save charts as GIF images in Excel9.png

Step6: In the “Save as Picture” dialog box, select “GIF” as the file type. Choose a file name and location for the GIF image, and click “Save“.

How to Save charts as GIF images in Excel10.png

Save charts as GIF images with VBA Code

If you want to save all charts in the active workbook as GIF images with VBA code in Microsoft Excel Spreadsheet, you can do the following steps:

Step1: Open your workbook that contains the charts you want to save as GIF images.

Step2: Press Alt + F11 on your keyboard to open the Visual Basic Editor (VBE).

Save or Export Excel Chart as Picture with VBA Code

Step3: In the VBE, go to “Insert” on the menu bar and select “Module” to create a new module.

Save or Export Excel Chart as Picture with VBA Code

Step4: Copy and paste the VBA code into the new module. Close the VBE and go back to the Excel workbook.

vba to Save charts as GIF images in Excel1.png
Sub SaveChartsAsGIF_excelgeek()
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim co As ChartObject
    Dim i As Integer
    Dim folderPath As String
    
    Set wb = ActiveWorkbook
    
    'Prompt user to select a folder to save the GIF images
    With Application.FileDialog(msoFileDialogFolderPicker)
        .Title = "Select a folder to save GIF images"
        .AllowMultiSelect = False
        If .Show <> -1 Then Exit Sub
        folderPath = .SelectedItems(1)
    End With
    
    For Each ws In wb.Worksheets
        For Each co In ws.ChartObjects
            i = i + 1
            co.Chart.Export folderPath & "\Chart" & i & ".gif", "GIF"
        Next co
    Next ws
End Sub

Step5: Press Alt + F8 on your keyboard to open the “Macro” dialog box. Select the “SaveChartsAsGIF_excelgeek” macro from the list of macros and click “Run“.

vba to Save charts as GIF images in Excel2.png

Step6: select a folder to save the GIF images.

vba to Save charts as GIF images in Excel3.png

Step7: The VBA code will then run and save all charts in the workbook as GIF images in the selected folder.

Conclusion

Saving charts as GIF images is useful when you want to share your charts with others who may not have access to your Excel workbook, or when you want to use the charts in a presentation or on a website.

How to Save Chart as TIFF Image in Excel

This post will guide you through three different methods to save a chart as a TIFF image in Excel 2013/2016/2019/365.

The first method involves using the “Save As Picture” feature in Excel, which allows you to save a selected chart as a TIFF image with just a few clicks.

The second method involves using the “Copy and Paste” feature to copy the chart as an image and then save it as a TIFF file using an image editing program.

The third and most advanced method involves using VBA code to automate the process of exporting multiple charts as TIFF images.

Save or Export Excel Chart as Picture using Save As Picture Feature

To save or export an Excel chart as a TIFF image using the “Save As Picture” feature, follow these steps:

Step1: Select the chart you want to save as a TIFF image.

How to save chart as TIFF image in Excel 1.png

Step2: Right-click on the chart and select “Save As Picture” from the context menu.

How to save chart as TIFF image in Excel2.png

Step3: In the “Save As Picture” dialog box, select “TIFF” as the file type. Choose the destination folder where you want to save the TIFF image and enter a name for the file.

How to save chart as TIFF image in Excel3.png

Step4: Click the “Save” button to save the chart as a TIFF image.

That’s it! The chart will be saved as a TIFF image in the selected destination folder with the specified filename.

Copy and Paste the Chart as TIFF Image

You can also use Copy and Paste feature to save the selected chart as TIFF image. Just do the following steps:

Step1: Open the Excel spreadsheet that contains the chart you want to save as a TIFF image.

Step2: Click on the chart to select it. Press “Ctrl + C” to copy the chart.

How to save chart as TIFF image in Excel4.png

Step3: Open your preferred image editor (such as Microsoft Paint or Adobe Photoshop).

Step4: Press “Ctrl + V” to paste the chart into the image editor.

How to save chart as TIFF image in Excel5.png

Step5: In the image editor, choose the “Save As” option from the “File” menu. Choose the location where you want to save the TIFF image. Select “TIFF” or “TIFF Image (.tif;.tiff)” in the “Save As Type” dropdown menu. Enter a file name for the TIFF image.

How to save chart as TIFF image in Excel6.png

Step6: Click on the “Save” button.

How to save chart as TIFF image in Excel7.png

Copy and Paste the Chart with VBA Code

If you want to save all charts as TIFF images in an Excel workbook, and you can use a VBA code to do it. Just follow these steps:

Step1: Open your Excel workbook containing the charts.

Step2: Press “Alt + F11” to open the VBA editor.

Step3: In the editor, go to “Insert” > “Module” to create a new module.

Step4: Copy and paste the below code into the module.

VBA save chart as TIFF image in Excel 1.png
Sub SaveChartsAsTIFF_excelgeek()
    Dim myChart As ChartObject
    Dim myPath As Variant
    Dim myFile As String
    
    'Prompt user to select the destination folder
    With Application.FileDialog(msoFileDialogFolderPicker)
        .Title = "Select Destination Folder"
        .AllowMultiSelect = False
        If .Show <> -1 Then Exit Sub
        myPath = .SelectedItems(1)
    End With
    
    'Loop through all chart objects in the workbook
    For Each myChart In ActiveSheet.ChartObjects
        myChart.Chart.Export Filename:=myPath & "\" & myChart.Name & ".tif", FilterName:="TIFF"
    Next myChart
    
    'Display message box when all charts are saved
    MsgBox "All charts have been saved as TIFF images in the selected folder."
    
End Sub

Step5: Press “Alt + F8” to open the Macro dialog box.Select the “SaveChartsAsTIFF_excelgeek” macro and click “Run“.

VBA save chart as TIFF image in Excel 2.png

Step6: When prompted, select the destination folder where you want to save the TIFF images.

VBA save chart as TIFF image in Excel 3.png

Step7: Click “OK” and the macro will save all charts as TIFF images to the selected folder.

Conclusion

Saving charts as TIFF images in Excel is a useful and easy-to-accomplish task that can be done using different methods. If you need to export multiple charts as TIFF images, VBA code provides an efficient and automated solution.

How to Save Shapes as Images in Excel

This post will introduce you to three methods for saving shapes as images in Excel.

  • The first method involves using the copy and paste functionality to manually copy each shape to a temporary chart and then save the chart as an image.
  • The second method uses VBA code to automate the process of copying the shapes to a chart and saving the chart as an image.
  • The third method involves saving the worksheet as a web page, which automatically saves each shape as an individual image file.

Save Shapes as Images Using the “Copy and Paste” option

Step1: Select the shape you want to save as an image.

How to Save or Export Excel Chart as Image1.png

Step2: Press “Ctrl + C” to copy the shape to the clipboard.

Step3: Open a new Microsoft Paint file or any image editing software of your choice. Press “Ctrl + V” to paste the shape onto the new file.

How to Save or Export Excel Chart as Image2.png

Step4: Save the file in your desired file format (such as PNG or JPEG) and select a location to save the image.

How to Save or Export Excel Chart as Image3.png

This method is useful for saving multiple shapes as images or for making edits to the shape before saving it as an image.

Save All Shapes as Image Using “saving as web page”

You can save all shapes on a worksheet as individual images by using Excel’s “Save as Web Page” feature. This feature converts the worksheet into a webpage and saves it along with all embedded objects, including shapes, as separate image files. Here’s how you can do it:

Setp1: Select the worksheet that contains the shapes you want to save as images.

Setp2: Click on “File” in the top left corner of the Excel window and select “Save as“. Select “Web Page (.htm;.html)” in the “Save as type” dropdown menu. Choose a location to save the file and enter a file name.

How to Save or Export Excel Chart as Image4.png

Setp3: In the “Save As” dialog box, make sure that the “Selection: Sheet” option is selected. Click on Save button.

How to Save or Export Excel Chart as Image5.png

Step4: click on Publish buttonin the Publish as Web Page dialog box.

How to Save or Export Excel Chart as Image62.png

Setp5: Excel will now save the worksheet as a webpage, along with all embedded objects, including shapes, as separate image files in a folder named “yourfilename_files” (where “yourfilename” is the name you gave to the file in step 2).

How to Save or Export Excel Chart as Image7.png

Setp6: Navigate to the folder where you saved the file, and you should see all of the images that correspond to the shapes on the worksheet.

How to Save or Export Excel Chart as Image8.png

Save Shapes as Image with VBA Code

You can use the VBA code to create a temporary chart object, pastes the selected shape inside the chart, and then saves the chart as an image. Just do the following steps:

Step1: Open the Excel workbook that contains the shapes you want to save as images.

Step2: Press Alt + F11 to open the Visual Basic Editor.

Step3: In the Visual Basic Editor, select Insert from the menu bar and choose Module.

Step4: Copy the following VBA code for saving shapes as images and paste it into the new module (Module1).

Sub sleep(T As Single)
    Dim time1 As Single
    time1 = Timer
    Do
        DoEvents
    Loop While Timer - time1 < T
End Sub

Sub SaveShapeAsImage_excelgeek()
    Dim shp As Shape
    Dim savePath As String, fileName As String, fileFormat As String
    Dim cht As ChartObject
    Dim UserSelection As Variant
    
    Set UserSelection = ActiveWindow.Selection
    Set shp = ActiveSheet.Shapes(UserSelection.Name)
    
    ' prompt user for save location and file name
    savePath = Application.GetSaveAsFilename(InitialFileName:=shp.Name, _
        FileFilter:="JPEG (*.jpg), *.jpg, PNG (*.png), *.png")
    If savePath = "False" Then Exit Sub ' exit if user clicks cancel
    
    ' extract file name and format from save path
    fileName = Mid(savePath, InStrRev(savePath, "\") + 1)
    fileFormat = Mid(fileName, InStrRev(fileName, ".") + 1)
    fileName = Left(fileName, InStrRev(fileName, ".") - 1)
    
    ' create temporary chart object, set dimensions to shape dimensions, paste shape inside, and save as image
    Set cht = ActiveSheet.ChartObjects.Add(0, 0, shp.Width, shp.Height)
    shp.Copy
    Call sleep(2)
    cht.Chart.Paste
    cht.Chart.Export savePath, fileFormat
    cht.Delete
    Application.CutCopyMode = False
    
End Sub

Step5: Press F5 or select Run from the menu bar to execute the code. Or Press ALT + F8 to open the Macro dialog box. Then select the macro named “SaveShapeAsImage_excelgeek” from the list of macros and click on “Run”.

vba to Save or Export Excel Chart as Image2.png

Step6: you need to specify the file format and location for the saved image.

vba to Save or Export Excel Chart as Image3.png

Step7: Check the file path you specified in the code to confirm that the images have been saved successfully.

vba to Save or Export Excel Chart as Image4.png

Conclusion

There are three methods for saving shapes as images in Excel. The method you choose will depend on your specific needs and preferences. Whether you prefer a manual approach or an automated one, these methods provide several options for saving shapes as images in Excel.

How to Save or Export Excel Chart as PDF

This post will guide you on how to save or export Excel charts as PDF using the move chart feature and VBA code. And we will provide you with the necessary steps to export multiple charts into a PDF file.

The move chart feature allows you to easily move charts to a new worksheet, which is useful when exporting multiple charts. Additionally, we will provide VBA code that automates the process of exporting multiple charts into a single PDF file.

Save one Chart to a PDF Page

You can save an Excel chart as a PDF page by following these steps:

Step1: Select the chart you want to save as a PDF.

How to Save or Export Excel Chart as PDF 1.png

Step2: Click on the “File” menu in Excel, then select “Save As“. the “Save As” dialog box will open. Choose the location where you want to save the PDF file. In the “Save as type” dropdown menu, select “PDF (*.pdf)”. Enter a name for the PDF file in the “File name” field.

How to Save or Export Excel Chart as PDF 21.png

Step3: Click on the “Options” button to open the “Options” dialog box.

How to Save or Export Excel Chart as PDF 3.png

Step4:  In the “Options” dialog box, choose the “Selected chart” option under the ” Publish What” section.

How to Save or Export Excel Chart as PDF 4.png

Step5: Click on the “OK” button to close the “Options” dialog box.

Step6: Click on the “Save” button to save the chart as a PDF file.

How to Save or Export Excel Chart as PDF 5.png

The resulting PDF file will contain only the selected chart and nothing else.

Export Multiple Charts into one PDF File using Move Chart

If you need to print several charts, it can be more efficient to print them all at once in one document rather than printing them separately.

Here are the steps to export multiple charts into one PDF file:

Step1: Select the first chart you want to export.

Step2: Right-click on one of the selected charts and choose “Move Chart“. The “Move Chart” dialog box will open.

export multiple excel charts as pdf 1.png

Step3: In the “Move Chart” dialog box, select the “New sheet” radio button and click “OK“.

export multiple excel charts as pdf 2.png

Step4: Repeat steps 1-3 for each chart you want to export.

export multiple excel charts as pdf 3.png

Step5: Select all of the charts by holding down the Ctrl key and clicking on each chart sheet tab that you want to export.

export multiple excel charts as pdf 4.png

Step6: Click on the “File” menu and choose “Save As“. Choose “PDF” as the file type in the “Save As” dialog box. Enter a name for the PDF file.

export multiple excel charts as pdf 5.png

Step7: In the “Save As” dialog box, choose the option “Active sheet” under “Publish what“. Click on the “OK” button to close the dialog box.

export multiple excel charts as pdf 6.png

Step8: Click on the “Save” button to save the PDF file.

export multiple excel charts as pdf 7.png

You can see that the last PDF file will contain one page for each chart you exported, with each chart on a separate page.

Export Multiple Charts into one PDF File with VBA Code

You can save or export multiple charts in the active workbook into one PDF file using VBA Code in Excel, and each chart is in a separate page. Just do the following steps:

Step1: Open your Excel workbook that contains the charts you want to export.

export multiple excel charts as pdf vba 1.png

Step2: Press “Alt + F11” to open the Microsoft VBA Editor.

Step3: In the VBA Editor, click “Insert” from the top menu, then choose “Module“.

Step4: In the new module, paste the below VBA code.

export multiple excel charts as pdf vba 2.png
Sub ExportAllChartsToPDF_excelgeek()
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim co As ChartObject
    Dim exportSheet As Worksheet
    Dim chartCount As Integer
    Dim fileSaveName As Variant
    Dim chartWidth As Integer
    Dim chartHeight As Integer
    Dim chartTop As Integer
    Dim chartLeft As Integer
    
    ' Set a reference to the active workbook
    Set wb = ActiveWorkbook
    
    ' Create a new worksheet to export the charts
    Set exportSheet = wb.Worksheets.Add
 
    'Copy each chart to the export sheet
    For Each mySheet In wb.Worksheets
        For Each myChart In mySheet.ChartObjects
            chartCount = chartCount + 1
            If chartCount > 0 Then
                exportSheet.HPageBreaks.Add Before:=exportSheet.Cells(chartCount * 30, 1)
                'exportSheet.Cells(chartCount * 30, 1).Select
            End If
            myChart.Chart.ChartArea.Copy
            exportSheet.Paste Destination:=exportSheet.Cells(chartCount * 30 - 29, 1)
            
        Next myChart
    Next mySheet
    
    ' Check if any charts were exported
    If chartCount = 0 Then
        MsgBox "No charts found in workbook."
        exportSheet.Delete
        Exit Sub
    End If
    

    
    ' Export the export sheet as a PDF file
    fileSaveName = Application.GetSaveAsFilename(fileFilter:="PDF Files (*.pdf), *.pdf", Title:="Save PDF File")
    If fileSaveName <> False Then
        'exportSheet.ExportAsFixedFormat Type:=xlTypePDF, fileName:=fileSaveName
        exportSheet.ExportAsFixedFormat Type:=xlTypePDF, fileName:=fileSaveName, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False

    End If
    
    ' Delete the export sheet
    Application.DisplayAlerts = False
    exportSheet.Delete
    Application.DisplayAlerts = True
End Sub

Step5: Run the code by clicking the “Run” button or pressing “F5“. Or Press ALT + F8 to open the Macro dialog box or click on Macros command under Code group. Then select the macro named “ExportSelectedChartAsPicture_excelgeek” from the list of macros and click on “Run”.

export multiple excel charts as pdf vba 3.png

Step6: choose one location where you want to save the PDF file.

export multiple excel charts as pdf vba 4.png

Step7: The code will export all the charts in your workbook into one PDF file and save it to your specified location.

export multiple excel charts as pdf vba 5.png

Conclusion

Exporting charts as PDFs is useful when you need to share or print them. If you have multiple charts in your Excel document and want to export them as a single PDF file with each chart on a separate page, you can use the VBA code provided in this article.