Icarus38376
New Member
- Joined
- Jun 14, 2019
- Messages
- 6
Hello Folks, I'm new at this so any help appreciated.
I have a form that starts on Workbook_Open. It simply displays an image that gets updated form another system. When the user select the Option_Button1, the code should get the picture, wait 5 seconds and then redisplay it. It does work most of the time, However many time it just stops without error. Also, the label1.caption shows me that the loop is still running, but the picture is not updated. The image has the date and time it was generated, that is how we know it has not been updated. IF yo go directly to the image, the time may be much later than shows on the form. Could it be that the image is getting cached? Any help appreciated.
I have a form that starts on Workbook_Open. It simply displays an image that gets updated form another system. When the user select the Option_Button1, the code should get the picture, wait 5 seconds and then redisplay it. It does work most of the time, However many time it just stops without error. Also, the label1.caption shows me that the loop is still running, but the picture is not updated. The image has the date and time it was generated, that is how we know it has not been updated. IF yo go directly to the image, the time may be much later than shows on the form. Could it be that the image is getting cached? Any help appreciated.
Code:
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]'This Opens the Form
Private Sub Workbook_Open()
bigStatusForm.Show vbModal
End Sub[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]'This start the loop to update the picture
Private Sub OptionButton1_Click()
Do While OptionButton1.Value = True
i = i + 1
WasteTime (5)
Call doCopo
bigStatusForm.Label1.Caption = i
Loop
End Sub[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]
Sub doCopo()
On Error Resume Next
myPicture = "\\Desktop-iuf6vi7\Applications\Jobs\Reports\COPO_Status.jpg"[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]If Application.Workbooks.Count > 1 Then
WasteTime (5)
Else
IsFile = ((GetAttr(myPicture) And vbDirectory) <> vbDirectory)
If IsFile = True Then
Call getPicture(myPicture)
End If
End If
End Sub[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]
Sub getPicture(myPicture)
bigStatusForm.Image1.Picture = LoadPicture(myPicture)
End Sub[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif]
Sub WasteTime(Seconds As Long)
Dim EndTime As Double
EndTime = Time() + Seconds / 24 / 60 / 60
Do
DoEvents
Loop Until Time() >= EndTime
End Sub[/FONT]
[FONT=Verdana,Arial,Tahoma,Calibri,Geneva,sans-serif][/FONT]