I am not the nest with VBA so I have searched around the internet and come up with the following code that allows a user to press a button, a screen shot of the worksheet captured which is then pasted into an Outlook message which can then be sent to myself. This is being used for training and a record of this training.
It works 95% of the time but I have two problems with this
1) The VBA that I have seems to have been created for graphs. Not always but sometimes, a graph will appear in the screenshot even though there is no graph within the excel sheet. Sometimes this completely overwrites the worksheet and sometimes it only appears slightly but messes with the formatting. A screenshot of this is shown at https://screenshot.net/eyqo4t1
2) I have tested this worksheet successfully on three out of four PCs. The one PC that it did not work on, it only took a plain white screen shot (showing nothing). This PC is using Office 2016 whereas the others, including mine, use 2013. I need this to work on both versions of Office.
Below is my code
Can someone help with any tweaks or amendments that I can make to this to try to stop these problems?
Thanks
It works 95% of the time but I have two problems with this
1) The VBA that I have seems to have been created for graphs. Not always but sometimes, a graph will appear in the screenshot even though there is no graph within the excel sheet. Sometimes this completely overwrites the worksheet and sometimes it only appears slightly but messes with the formatting. A screenshot of this is shown at https://screenshot.net/eyqo4t1
2) I have tested this worksheet successfully on three out of four PCs. The one PC that it did not work on, it only took a plain white screen shot (showing nothing). This PC is using Office 2016 whereas the others, including mine, use 2013. I need this to work on both versions of Office.
Below is my code
Code:
Private Sub cmdMainMenu_Click()
frmMainMenu.Show
End Sub
Private Sub cmdEmail_Click()
'Application.ScreenUpdating = False ' this stops new chart from being displayed all the time - this seems to produce a white screen
Dim oRange As Range
Dim oCht As Chart
Dim oImg As Picture
Set oRange = Range("A1:P34")
Set oCht = Charts.Add
oRange.CopyPicture xlScreen, xlPicture
oCht.Paste
oCht.Export Filename:="C:\_Training\_System\Completed_Module.jpg", Filtername:="JPG"
Application.DisplayAlerts = False ' turns prompts off so that chart is deleted automatically; no user prompt
oCht.Delete
Application.DisplayAlerts = True ' turns prompts back on
MsgBox "Images have been created. ", vbInformation 'messagebox with text and OK-button
Application.ScreenUpdating = True ' this turns screen updating back on.
'ActiveSheet.Protect ' place at end of code
Screenshot_Mail "me@emailaddress.co.uk" & "; " & "", "" & _
"; " & "" & "; " & "", Range("R1"), "[COLOR=red]" & _
"[I]" & "Below is a Snapshot View of the Training Completed: " & "[/I][/COLOR][I]" & "[/I]" & _
"
" & "
" & "******>[FONT=Arial][SIZE=2][COLOR=#000080][/COLOR][/SIZE][/FONT]" & _
"[IMG]https://www.mrexcel.com/forum/_Training\_System\Completed_Module.jpg[/IMG] "
End Sub
Private Sub cmdPrint_Click()
Worksheets("Printable_Version").Activate
Dim sh As Worksheet
Dim rngPrint As Range
Set sh = ActiveSheet
Set rngPrint = ActiveCell.CurrentRegion
With sh.PageSetup
.Orientation = xlLandscape
.Zoom = False
.FitToPagesTall = 1
.FitToPagesWide = 1
End With
rngPrint.PrintPreview
'Worksheets("Printable_Version").PrintPreview
'Worksheets("Printable_Version").PrintPreview
'Sheets("Printable_Version").PrintOut
End Sub
Can someone help with any tweaks or amendments that I can make to this to try to stop these problems?
Thanks