How to remove image borders when exporting from Excel?


DT

Here is an image of my code exporting from excel to file

For Each oShape In ActiveSheet.Shapes
    strImageName = oShape.TopLeftCell.Row & "_" & oShape.TopLeftCell.Column
    If oShape.Type = msoPicture Then
        oShape.Select
        'Picture format initialization
        Selection.ShapeRange.PictureFormat.Contrast = 0.5: Selection.ShapeRange.PictureFormat.Brightness = 0.5: Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomatic: Selection.ShapeRange.PictureFormat.TransparentBackground = msoFalse: Selection.ShapeRange.Fill.Visible = msoFalse: Selection.ShapeRange.Line.Visible = msoFalse: Selection.ShapeRange.Rotation = 0#: Selection.ShapeRange.PictureFormat.CropLeft = 0#: Selection.ShapeRange.PictureFormat.CropRight = 0#: Selection.ShapeRange.PictureFormat.CropTop = 0#: Selection.ShapeRange.PictureFormat.CropBottom = 0#: Selection.ShapeRange.ScaleHeight 1#, msoTrue, msoScaleFromTopLeft: Selection.ShapeRange.ScaleWidth 1#, msoTrue, msoScaleFromTopLeft
        '/Picture format initialization
        Application.Selection.CopyPicture
        Set oDia = ActiveSheet.ChartObjects.Add(0, 0, oShape.Width, oShape.Height)
        Set oChartArea = oDia.Chart
        oDia.Activate
        With oChartArea
            .ChartArea.Select
            .Paste
            .Export ("D:\images\" & strImageName & ".jpg")
        End With
        oDia.Delete 'oChartArea.Delete
    End If
Next

The original image does not have a border, but in the resulting file there is an image with a large border:

enter image description here

How to keep the original image when exporting from Excel?

Sterilize

The border is on the chart from which the image is to be exported , not on the image itself. so:

    Set oChartArea = oDia.Chart
    'No need to Activate the ChartObject
    With oChartArea
        .ChartArea.Format.Line.Visible = msoFalse 'No Outline
        .ChartArea.Format.Fill.Visible = msoFalse 'No Background
        .ChartArea.Paste 'No need to use Select
        .Export ("D:\images\" & strImageName & ".jpg")
    End With
    oDia.Delete

You can see this more clearly just by running ActiveSheet.ChartObjects.Add 0, 0, 100, 100in the Immediate Window ( Ctrl+ in VBE G) and observing the ChartObject's default settings (including outlines) .

Related


How to remove image borders when exporting from Excel?

DT Here is an image of my code exporting from excel to file For Each oShape In ActiveSheet.Shapes strImageName = oShape.TopLeftCell.Row & "_" & oShape.TopLeftCell.Column If oShape.Type = msoPicture Then oShape.Select 'Picture format ini

How to remove image borders when exporting from Excel?

DT Here is an image of my code exporting from excel to file For Each oShape In ActiveSheet.Shapes strImageName = oShape.TopLeftCell.Row & "_" & oShape.TopLeftCell.Column If oShape.Type = msoPicture Then oShape.Select 'Picture format ini

remove image when exporting excel from gridview

Umm E Habiba Siddiqui I am exporting excel from gridview but it is not giving me nice formatting. The image is displayed on the excel file. I don't need these images, what should I do? this is my code protected void Export_to_Excel(object sender, EventArgs e)

How to remove export to Excel warning when exporting datatable

Luis Valencia I have the following code, the datatable already has data and I want to export it to excel. But I get the following warning, I tried xlsx and it doesn't work. I also tried csv and the data is not opening into columns as desired. public static voi

Remove images when exporting GridView to Excel

Ayman I have a parent gridview with positive/negative images that can be used to expand the parent gridview to see nested gridviews. My problem is when I export the grid view to show the plus/minus image in excel as a blank image, I get it as a blank image in

Remove "?" from calculated fields when exporting

Sean I have many calculated fields in my report, some just have a "?" instead of a calculated answer, and while I don't really care about that, it does make me very uncomfortable when I export my report and see the "?" annoyed. the entire spreadsheet. My quest

Remove quotes from strings in Clickhouse when exporting

Jiga Mehta I am trying to export data from clickhouse cli to csv. I have a string field that when exported to CSV has quotes around the field. I want to export quotesbut can't find any settings that I can set. I went through https://clickhouse.yandex/docs/en/i

Remove labels from graph when exporting

dark pool My chart contains a custom label which I place on the bottom left like this: events: { load: function () { var label = this.renderer.label('Custom label goes here') .css({ width: '450px', color:

Remove image borders with JavaScript

Grosk I have an image with a border that should not work in Chrome, Safari, IE and Opera, but not in Firefox. I'm assuming it's a browser default issue, but I'm working on removing it because it's running as an AB split test and I can't modify the basic html/c

Remove image borders with JavaScript

Grosk I have an image with a border that should not work in Chrome, Safari, IE and Opera, but not in Firefox. I'm assuming it's a browser default issue, but I'm working on removing it because it's running as an AB split test and I can't modify the basic html/c

Data lost when exporting from GridView to Excel

Sunil gupta During excel export from gridview the data for the column called "Account Prefix" 0 is removed. please guide me likewise username You need to put the Account number into a string variable to protect the leading zeros, then when exporting to excel y

Data lost when exporting from GridView to Excel

Sunil gupta During excel export from gridview the data for the column called "Account Prefix" 0 is removed. please guide me likewise username You need to put the Account number into a string variable to protect the leading zeros, then when exporting to excel y

How to completely remove borders from HTML tables

yazanpro My goal is to make an HTML page that resembles a "picture frame". In other words, I'm making a blank page with 4 images around it. Here is my code: <table> <tr> <td class="bTop" colspan="3"> </td> </tr> <tr> <td cla

How to completely remove borders from HTML tables

yazanpro My goal is to make an HTML page that resembles a "picture frame". In other words, I'm making a blank page with 4 images around it. Here is my code: <table> <tr> <td class="bTop" colspan="3"> </td> </tr> <tr> <td cla

How to remove padding and borders from table cells?

Lego I tried a lot of solutions found here and in google, but none of them worked. The table is dynamically generated by jQuery and Javascript. Question: How can I remove padding and borders between cells in this html table? Here is the HTML code:- <div class=

How to remove borders from images in Chrome?

Christian 85 I have a web application with an image tag that has a css class but no attributes. Something like this:src <img class="image"/> The css class only defines the url of the image and its size, but not the border property. The problem is that the whi

How to remove similar borders from input?

Salvador Dali I would like to achieve the same effect with inputelement as with contenteditableattribute . What I did can be seen in jsFiddle . HTML: <div class="greenStripe"> <input placeholder="Title" class='t'/> </div> CSS: .greenStripe{ backgrou

How to remove similar borders from input?

Salvador Dali I would like to achieve the same effect with element that I can achieve inputwith contenteditableattribute . What I did can be seen in jsFiddle . HTML: <div class="greenStripe"> <input placeholder="Title" class='t'/> </div> CSS: .greenStri

How to completely remove borders from HTML tables

yazanpro My goal is to make an HTML page that resembles a "picture frame". In other words, I'm making a blank page with 4 images around it. Here is my code: <table> <tr> <td class="bTop" colspan="3"> </td> </tr> <tr> <td cla

How to remove borders from images in Chrome?

Christian 85 I have a web application with an image tag that has a css class but no attributes. Something like this:src <img class="image"/> The css class only defines the url of the image and its size, but not the border property. The problem is that the whi

How to remove similar borders from input?

Salvador Dali I would like to achieve the same effect with element that I can achieve inputwith contenteditableattribute . What I did can be seen in jsFiddle . HTML: <div class="greenStripe"> <input placeholder="Title" class='t'/> </div> CSS: .greenStri

How to hide to columns when exporting GridView to Excel?

Alan Sellers How to hide two columns when exporting GridViewto excel . So now this is what it looks like when I export: ------------------------------------------------------------------------- | Display Name | Email Address | License | |

How to hide to columns when exporting GridView to Excel?

Alan Sellers How to hide two columns when exporting GridViewto excel . So now this is what it looks like when I export: ------------------------------------------------------------------------- | Display Name | Email Address | License | |