dpConsulendo
New Member
- Joined
- Jan 20, 2015
- Messages
- 6
Hi Guys,
I am having difficulty running a small report via Task Scheduler. It works fine updating form the database but this last code gives me a headache.
The error says:
Any hints??
I am having difficulty running a small report via Task Scheduler. It works fine updating form the database but this last code gives me a headache.
The error says:
"Run-time error '91':
Object cariable or With block varible not set
I know its the highligthed with red color, but just can't get around it.. Any hints??
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Const FName As String = "\\srv1\Data\KPI.png"
Dim pic_rng As Range
Dim ShTemp As Worksheet
Dim ChTemp As Chart
Dim PicTemp As Picture
Application.ScreenUpdating = False
Set pic_rng = Worksheets("Dashboard").Range("E17:AO77")
Set ShTemp = Worksheets.Add
Charts.Add
[SIZE=4][FONT=arial black][COLOR=#ff0000]ActiveChart.Location Where:=xlLocationAsObject, Name:=ShTemp.Name[/COLOR][/FONT][/SIZE]
Set ChTemp = ActiveChart
pic_rng.CopyPicture Appearance:=xlScreen, Format:=xlPicture
ChTemp.Paste
Set PicTemp = Selection
With ChTemp.Parent
.Width = 1920
.Height = 940
End With
ChTemp.Export Filename:="\\srv1\Data\KPI.png", FilterName:="png"
Application.DisplayAlerts = False
ShTemp.Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True
End Sub