Preciso atribuir uma imagem que apareça a cada 1 hora no EXCEL, como?! Provavelmente será necessário utilizar o VBA. Mas não sou muito familiarizado.
E que feche sozinha após 1 minuto.
Stack Overflow em Português é um site de perguntas e respostas para programadores profissionais e entusiastas. Leva apenas um minuto para se inscrever.
Inscreva-se para participar desta comunidadePreciso atribuir uma imagem que apareça a cada 1 hora no EXCEL, como?! Provavelmente será necessário utilizar o VBA. Mas não sou muito familiarizado.
E que feche sozinha após 1 minuto.
Use este código VBA para agendar tarefas no horário desejado:
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
Este é usado para mostrar a imagem e o caminho da imagem deve ser escrito em 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
Esta é uma função para lidar com erro, caso o caminho da imagem não encontre nada.
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
Este Sub é chamado 1 minuto após inserir a imagem.
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