Nayasoch
Board Regular
- Joined
- Sep 9, 2016
- Messages
- 73
I have this code which doesn't work and when I complie and run It shows Error Variable not defined and highlights the CurrentChart or ChartNum.
As I am aware Dim var1, var2 can be declared but in my case it is not working if I remove
It works again perfectly .
My Code which shows errors of variables not defined.
Any help would be rightly appreciated.
As I am aware Dim var1, var2 can be declared but in my case it is not working if I remove
Code:
Dim ret As Long
Dim formHWnd As Long
It works again perfectly .
My Code which shows errors of variables not defined.
Code:
Option Explicit
Dim ChartNum As Integer
Private Sub UserForm_Initialize()
ChartNum = 1
UpdateChart
Const C_VBA6_USERFORM_CLASSNAME = "ThunderDFrame"
Dim ret As Long
Dim formHWnd As Long
'Get window handle of the userform
formHWnd = FindWindow(C_VBA6_USERFORM_CLASSNAME, Me.Caption)
If formHWnd = 0 Then
Debug.Print Err.LastDllError
End If
'Set userform window to 'always on top'
ret = SetWindowPos(formHWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
If ret = 0 Then
Debug.Print Err.LastDllError
End If
End Sub
Private Sub UpdateChart()
Set CurrentChart = Sheets("Graph1").ChartObjects(ChartNum).Chart
CurrentChart.Parent.Width = 380
CurrentChart.Parent.Height = 260
' Save chart as GIF
Fname = ThisWorkbook.Path & Application.PathSeparator & "temp.gif"
CurrentChart.Export FileName:=Fname, FilterName:="GIF"
' Show the chart
Image1.Picture = LoadPicture(Fname)
End Sub
Any help would be rightly appreciated.