Snapshot as a popup

AngleseyExcel

New Member
Joined
Feb 4, 2021
Messages
38
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

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
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,223,270
Messages
6,171,103
Members
452,379
Latest member
IainTru

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