Hello,
i have a file that i automatically set to load another file.
after the file is loaded i would like to automatically close the initial file.
i have used the below code to close the file but the problem is that i have a addin that automatically prompts a message box to clasify the file before closing.
i was thinking to use the sendkeys ( i need to press tab and then enter to chosse the "NO" button on the message box that apperears) for this but it doesn't seem to be working.
can you please look into the code and advise?
i have a file that i automatically set to load another file.
after the file is loaded i would like to automatically close the initial file.
i have used the below code to close the file but the problem is that i have a addin that automatically prompts a message box to clasify the file before closing.
i was thinking to use the sendkeys ( i need to press tab and then enter to chosse the "NO" button on the message box that apperears) for this but it doesn't seem to be working.
can you please look into the code and advise?
Code:
Private Sub Workbook_Open()
WkbkName = ThisWorkbook.Name
curr_path = ActiveWorkbook.Path
now_stamp = Format(Now, "DDMMYY")
If Dir(curr_path & "\" & now_stamp & "_SOX_PRT_SCRNS_" & Application.UserName & ".xlsm") <> "" Then
Workbooks.Open Filename:=curr_path & "\" & now_stamp & "_SOX_PRT_SCRNS_" & Application.UserName & ".xlsm"
[B]Workbooks(WkbkName).Close False[/B]
[B]Application.SendKeys "{TAB}"
DoEvents
Application.SendKeys "{ENTER}"
DoEvents[/B]
Else
ActiveWorkbook.SaveAs Filename:= _
curr_path & "\" & now_stamp & "_SOX_PRT_SCRNS_" & Application.UserName & ".xlsm" _
, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
Application.WindowState = xlMaximized
MsgBox "Today's (" & Format(Now, "DD-mmm-yy") & ") SOX print screens file has been created. TO access it go to " & curr_path
End If
End Sub