L
Legacy 185660
Guest
Hey Everyone!
I have a macro that checks if a workbook has been opened from sharepoint, extracts data from it and puts it in my other workbook.
My problem right now is, when I open the timesheet.xls file I get given a "Protected View This file was opened from a potentially unsafe location." "Enable Editing"
I know that if I am on the window I use the code "Application.ActiveProtectedViewWindow.Edit" but I can't get the other window to activate.
This is my code right now, basically it will not find the window that is open because it is protected
I have a macro that checks if a workbook has been opened from sharepoint, extracts data from it and puts it in my other workbook.
My problem right now is, when I open the timesheet.xls file I get given a "Protected View This file was opened from a potentially unsafe location." "Enable Editing"
I know that if I am on the window I use the code "Application.ActiveProtectedViewWindow.Edit" but I can't get the other window to activate.
This is my code right now, basically it will not find the window that is open because it is protected
Code:
Sub ImportSheet()
'Will activate "Timesheet less than 37.5 hours.xls" window, if it does not exist it
'will find it. If it doesnt find it, it won't affect anything else
On Error Resume Next
Windows("Timesheet less than 37.5 hours.xls").Activate
Windows("Timesheet less than 37.5 hours (1).xls").Activate
Windows("Timesheet less than 37.5 hours (2).xls").Activate
Windows("Timesheet less than 37.5 hours (3).xls").Activate
Windows("Timesheet less than 37.5 hours (4).xls").Activate
Windows("Timesheet less than 37.5 hours (5).xls").Activate
'Checks to see if it has found the window to import data
If ActiveSheet.Name <> "Error Check" Then
'Checks to see if column E has been deleted yet
If Range("F5") <> "" Then
Columns("E:E").Delete Shift:=xlLeft
End If
'Copies data to new sheet
Range("B5:E" & WorksheetFunction.CountA(Range("B:B")) - 2).Copy
Windows("Time Entries.xlsm").Activate
Range("Table8[User]").Select
ActiveSheet.Paste
Else
MsgBox "Timesheet less than 37.5 hours.xls is not open" & vbNewLine & _
"Please open the spreadsheet and recheck 'Import Sheet'", vbCritical, "Import Sheet"
End If
End Sub