VBA code to save my worksheet as an image file to then place in HTML

LEG_END

Board Regular
Joined
Jan 8, 2017
Messages
65
Hi,

I am trying to save an image file that contains my worksheet. That can then be imported into my html code however, the image is small and becomes distorted as the size is increased... is there something I can do to say re-size the image before it is saved to allow me to keep the clarity my current code is as follows:

Code:
Private Sub CommandButton2_Click()
Dim sSheetName As Worksheet
Dim oRangeToCopy As Range
Dim oCht As Chart
Set sSheetName = Worksheets("Berthing_Board") ' worksheet to work on
Set oRangeToCopy = Range("A1:U42") ' range to be copied
sSheetName.Range("A1:U42").CopyPicture xlScreen, xlBitmap
Set oCht = Charts.Add
With oCht
    .Paste
    .Export Filename:="C:\Users\imust\Desktop\TESTER.bmp", Filtername:="BMP"
End With
End Sub

I basically want to share my worksheet to allow others to view it from the web be it mobile or desktop.

I have tried saving the workbook as .mht also and by placing this in an iframe in my html but for some reason mht wont display in IE or chrome. Hence why I am reverting to the image option.

This is way past anything I've ever tried before so learning as I go at the minute

any ideas will be greatly appreciated.

Thanks

Izzy
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
I can't give you any direct code but can suggest a couple of things to try.

You could save the image in Word first (default save is at 220 DPI but you can change to it better than this) then exporting that image to a file which gives a better resolution.

Alternatively you could try https://www.xltoolbox.net/scientificpublishing.html. I haven't used this myself so cannot attest to how well it works.
 
Upvote 0

Forum statistics

Threads
1,215,140
Messages
6,123,266
Members
449,093
Latest member
Vincent Khandagale

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