Opens Workbook without running AutoMacros and without letting the user know
Checks if it file is there, and if it is open first
Returns true or false
Function WorkbookOpen_ANmar(WBFull, Optional RunAutoMacros = 0, Optional CloseitifOpen = 1, Optional SaveitifClosing = 0)
' Opens workbooks without letting the user knows, and without running automacros
' Needs FindFile, GetSon, GetPapa, IsThere
WBFile = GetSon(WBFull)
WbFolder = GetPapa(WbFull)
Rett = False
If FindFile(WBFile) Then
If CloseitifOpen = 0 Then Exit Function
SaveMe = False
If SaveitifClosing = 1 Then SaveMe = True
DoEvents
Workbooks(WBFile).Close SaveMe
End If
If RunAutoMacros = 0 Then
secAutomation = Application.AutomationSecurity
Application.AutomationSecurity = msoAutomationSecurityForceDisable
End If
If IsThere(WbFile, WbFolder, True, True) Then
secScreen = Application.ScreenUpdating
Application.ScreenUpdating = False
Workbooks.Open WBFull
ThisWorkbook.Activate
Application.ScreenUpdating = secScreen
If RunAutoMacros = 0 Then
Application.AutomationSecurity = secAutomation
End If
Rett=true
Else
' Msgbox "File not found.." & vbcrlf & WbFull
End If
WorkbookOpen_ANmar = Rett
End Function
' Opens workbooks without letting the user knows, and without running automacros
' Needs FindFile, GetSon, GetPapa, IsThere
WBFile = GetSon(WBFull)
WbFolder = GetPapa(WbFull)
Rett = False
If FindFile(WBFile) Then
If CloseitifOpen = 0 Then Exit Function
SaveMe = False
If SaveitifClosing = 1 Then SaveMe = True
DoEvents
Workbooks(WBFile).Close SaveMe
End If
If RunAutoMacros = 0 Then
secAutomation = Application.AutomationSecurity
Application.AutomationSecurity = msoAutomationSecurityForceDisable
End If
If IsThere(WbFile, WbFolder, True, True) Then
secScreen = Application.ScreenUpdating
Application.ScreenUpdating = False
Workbooks.Open WBFull
ThisWorkbook.Activate
Application.ScreenUpdating = secScreen
If RunAutoMacros = 0 Then
Application.AutomationSecurity = secAutomation
End If
Rett=true
Else
' Msgbox "File not found.." & vbcrlf & WbFull
End If
WorkbookOpen_ANmar = Rett
End Function
WBFull, Optional RunAutoMacros, Optional CloseitifOpen, Optional SaveitifClosing
Views 3,890
Downloads 1,319
CodeID
DB ID