3
Need to assign an image that appears every 1 hour in EXCEL, how?! It will probably be necessary to use VBA. But I am not very familiar.
And close alone after 1 minute.
3
Need to assign an image that appears every 1 hour in EXCEL, how?! It will probably be necessary to use VBA. But I am not very familiar.
And close alone after 1 minute.
2
Use this VBA code to schedule tasks at the desired time:
Private Sub Workbook_Open()
'-- Roda os Subs ou funções no horário agendado.
'Deve ser colodado em EstaPastadeTrabalho
Application.OnTime TimeValue("10:00:00"), "mostrarImagem"
Application.OnTime TimeValue("12:00:00"), "mostrarImagem"
Application.OnTime TimeValue("14:00:00"), "mostrarImagem"
End Sub
This is used to display the image and the image path should be written in strPath
Sub mostrarImagem()
Debug.Print "mostrarImagem() rodou as " & Time
On Error GoTo 0
'INSERIR O CAMINHO DA IMAGEM AQUI
strPath = "C:/Caminho/do/arquivo/de/Imagem.jpg"
Inicio:
If Dir(strPath) <> "" Then
ActiveSheet.Pictures.Insert (strPath)
Application.ScreenUpdating = False
Application.DisplayFullScreen = True
Application.DisplayFormulaBar = False
ActiveWindow.DisplayWorkbookTabs = False
ActiveWindow.DisplayHeadings = False
ActiveWindow.DisplayGridlines = False
Application.OnTime Now() + CDate("00:01:00"), "fecharImagem"
Else
MsgBox "A imagem não pôde ser carregada - Escolha a imagem."
strPath = EscolherImagem
GoTo Inicio
End If
End Sub
This is a function to handle error if the image path does not find anything.
Public Function EscolherImagem() As String
'Créditos: http://software-solutions-online.com/excel-vba-open-file-dialog/
Dim intChoice As Long
Dim strPath As String
'only allow the user to select one file
Application.FileDialog(msoFileDialogOpen).AllowMultiSelect = False
'make the file dialog visible to the user
intChoice = Application.FileDialog(msoFileDialogOpen).Show
'determine what choice the user made
If intChoice <> 0 Then
'get the file path selected by the user
strPath = Application.FileDialog( _
msoFileDialogOpen).SelectedItems(1)
'print the file path to sheet 1
EscolherImagem = strPath
End If
End Function
This Sub is called 1 minute after inserting the image.
Sub fecharImagem()
'Sub agendado irá rodar por 1 minuto
ActiveSheet.Shapes(1).Delete
Application.DisplayFullScreen = False
Application.DisplayFormulaBar = True
ActiveWindow.DisplayWorkbookTabs = True
ActiveWindow.DisplayHeadings = True
ActiveWindow.DisplayGridlines = True
Application.ScreenUpdating = True
Debug.Print "mostrarImagem() parou as " & Time
End Sub
Browser other questions tagged excel excel-vba
You are not signed in. Login or sign up in order to post.
Where is the image located? On the web or on the computer? If on the computer, same Excel file folder?
– danieltakeshi
Please read the Manual on how NOT to ask questions, How we should format questions and answers? and Be more specific in the question
– danieltakeshi
Sorry, I did it by cell phone in the middle of the production line in the company. Yeah, it will be located on the computer. I want an image to appear and stay for 1 minute, in that 1 minute it’s for the employees to do stretch exercises for ergonomics, etc...
– Alex_Alex_Alex
Better, is it possible to put in specific intervals of time? Instead of being every 1 hour, as it has intervals, lunch hours, etc... Would it be for specific hours? 10:00 12:00 14:00, etc... It was 10:00, bam, the image appears that will stay for 1 minute to remember about ergonomics.
– Alex_Alex_Alex
Look for schedule tasks in VBA and then how to create a Sub to show images.
– danieltakeshi
My suggestion is that you use the Windows Task Scheduler to do this task. You can use it to schedule actions to be executed from time to time. In the action setting, you can ask to display an image.
– Fernando
Fernando, could you create the example of the task scheduler? I am since yesterday researching and just failed to date :/
– Alex_Alex_Alex
Fernando? Are you still there? Could you give an example? kk
– Alex_Alex_Alex