VBA Code to delete Grey Border from Image inside Excel

aayaanmayank

Board Regular
Joined
Jul 20, 2018
Messages
157
Hi
Can anyone please help me on this. i have created macro which create an image by collating text boxes and shapes. how while pasting that in to outlook i am getting Grey border. which i need to remove.
is there any way to remove.
below is the code which is creating image.
VBA Code:
Sub createcopy()
    Dim sh As Worksheet
    Dim lr As Variant
Application.DisplayAlerts = False

Set sh = ThisWorkbook.Sheets("Template")

lr = sh.Range("A" & Application.Rows.Count).End(xlUp).Row - 1

Worksheets("Template").Range("A1:Q" & lr).CopyPicture xlScreen, xlPicture
Sheets("Sheet1").Activate
Sheets("Sheet1").Paste
End Sub
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Maybe
VBA Code:
Sub Create_Copy()
    Dim sh As Worksheet, lr As Long
    Application.DisplayAlerts = False
        Set sh = ThisWorkbook.Sheets("Template")
        sh.Activate
        lr = sh.Range("A" & Application.Rows.Count).End(xlUp).Row - 1
        ActiveWindow.DisplayGridlines = False
            sh.Range("A1:Q" & lr).CopyPicture xlScreen, xlPicture
        ActiveWindow.DisplayGridlines = True
        With Sheets("Sheet1")
            .Activate: .Paste
        End With
    Application.DisplayAlerts = True
End Sub
 
Upvote 0
Maybe
VBA Code:
Sub Create_Copy()
    Dim sh As Worksheet, lr As Long
    Application.DisplayAlerts = False
        Set sh = ThisWorkbook.Sheets("Template")
        sh.Activate
        lr = sh.Range("A" & Application.Rows.Count).End(xlUp).Row - 1
        ActiveWindow.DisplayGridlines = False
            sh.Range("A1:Q" & lr).CopyPicture xlScreen, xlPicture
        ActiveWindow.DisplayGridlines = True
        With Sheets("Sheet1")
            .Activate: .Paste
        End With
    Application.DisplayAlerts = True
End Sub
I tried this one but my image is getting bit blur.
 
Upvote 0
This is a workaround to get rid of the grey borders as you request. I didn't get what you mean with fuzzy. Can you put snapshots of the desired output?
 
Upvote 0
This is a workaround to get rid of the grey borders as you request. I didn't get what you mean with fuzzy. Can you put snapshots of the desired output?
Pic1.gif
pic2.gif
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top