Snapshot as a popup

AngleseyExcel

New Member
Joined
Feb 4, 2021
Messages
36
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
VBA Code:
Option Explicit
Sub Rng_Snapshot()
 Dim rng As Range
 
 Application.ScreenUpdating = False
 
 Set rng = Sheet89.Range("U14:AU61")
 
 rng.CopyPicture
 
 On Error Resume Next
 
 Sheet4.Range("A1").PasteSpecial
 
 Set rng = Nothing
 
 Application.ScreenUpdating = True
 End Sub

I'm using the above code to create a snapshot of a range of data and post the snapshot into a seperate sheet. Is there any way if modifying it so it displays the snapshot as a popup window ?

Any help would be greatly appreciated. TIA
 

Excel Facts

Who is Mr Spreadsheet?
Author John Walkenbach was Mr Spreadsheet until his retirement in June 2019.
Hi AngelseyExcel and Welcome to this Board. The problem is that the range is really large. You can make a popup window sort of by adding a userform and placing a large frame control on it. You will need to add the following code....
Module code...
Code:
Public TempA As Double
Public TempB As Double
Public Sub createJpg(SheetName As String, xRgAddrss As Range, nameFile As String)
Dim xRgPic As Range
Application.ScreenUpdating = False
Worksheets(SheetName).Activate
Set xRgPic = xRgAddrss
xRgPic.CopyPicture
TempA = xRgPic.Width
TempB = xRgPic.Height
With ThisWorkbook.Worksheets(SheetName).ChartObjects.Add(xRgPic.Left, xRgPic.Top, xRgPic.Width, xRgPic.Height)
.Activate
.Chart.Paste
.Chart.Export Environ$("temp") & "" & nameFile & ".jpg", "JPG"
End With
Worksheets(SheetName).ChartObjects(Worksheets(SheetName).ChartObjects.Count).Delete
Application.ScreenUpdating = True
End Sub
Userform code...
Code:
Private Sub UserForm_Initialize()
With UserForm1.Frame1
.BorderStyle = fmBorderStyleNone
.Caption = vbNullString
.ScrollBars = fmScrollBarsBoth
.ScrollHeight = TempB
.ScrollWidth = TempA
.Picture = LoadPicture(Environ$("temp") & "" & "TempChart.jpg")
.PictureSizeMode = fmPictureSizeModeClip
End With
Kill (Environ$("temp") & "" & "TempChart.jpg")
End Sub
To operate with your range run this Test sub....
Code:
Sub test()
Call createJpg("Sheet89", ThisWorkbook.Worksheets("Sheet89").Range("U14:AU61"), "TempChart")
UserForm1.Show
End Sub
HTH. Dave
 
Upvote 0
Sub test() Call createJpg("Sheet89", ThisWorkbook.Worksheets("Sheet89").Range("U14:AU61"), "TempChart") UserForm1.Show End Sub
Hi Thanks for this, but this is specific to a certain sheet(Sheet89), how would i make it for the Active sheet that it's embedded on ?
 
Upvote 0
This was your requested range posted...
Code:
Set rng = Sheet89.Range("U14:AU61")
You can adjust this part of the code (sheet name and/or range) to whatever....
Code:
Call createJpg("Sheet89", ThisWorkbook.Worksheets("Sheet89").Range("U14:AU61"), "TempChart")
I'm not sure what's "embedded" here, but to use the active sheet you need to change this....
Code:
Sub test()
Dim SheetName As String
SheetName = ActiveSheet.Name
Call createJpg(SheetName, ThisWorkbook.Worksheets(SheetName).Range("A1:U69"), "TempChart")
UserForm1.Show
End Sub
Please, in the future, be clear on what your desired outcome is. Dave
 
Upvote 0
Solution
This was your requested range posted...
Code:
Set rng = Sheet89.Range("U14:AU61")
You can adjust this part of the code (sheet name and/or range) to whatever....
Code:
Call createJpg("Sheet89", ThisWorkbook.Worksheets("Sheet89").Range("U14:AU61"), "TempChart")
I'm not sure what's "embedded" here, but to use the active sheet you need to change this....
Code:
Sub test()
Dim SheetName As String
SheetName = ActiveSheet.Name
Call createJpg(SheetName, ThisWorkbook.Worksheets(SheetName).Range("A1:U69"), "TempChart")
UserForm1.Show
End Sub
Please, in the future, be clear on what your desired outcome is. Dave
Thank you so much for your help.
 
Upvote 0

Forum statistics

Threads
1,214,784
Messages
6,121,540
Members
449,038
Latest member
Guest1337

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