The problem with this code is that
"Function BookOpen(wbName As String) As Boolean", the "(wbName As String)", the wbName will change with each file I atempt to open. Also, the file is in a directory, so it needs to open the file from a path.
In my current macro I already have the path and each filename set As String. The following is part of macro I have already:
Sub Upload()</SPAN>
Dim UserInput As Variant</SPAN>
Dim wbFilename As String</SPAN>
Dim Count As Integer</SPAN>
Dim Forloop As Integer</SPAN>
Dim FirstRange As Range</SPAN>
Dim Foremost As String</SPAN>
Dim QA As String</SPAN>
Dim PremDisb As String</SPAN>
Dim FinReporting1 As String</SPAN>
Dim FinReporting2 As String</SPAN>
Dim PremRes As String</SPAN>
Dim PremAppControlandBal As String</SPAN>
Dim AgtCompensation As String</SPAN>
Dim Directory As String</SPAN>
Dim ForemostNum As Integer</SPAN>
Dim QANum As Integer</SPAN>
Dim Fin1Num As Integer</SPAN>
Dim Fin2Num As Integer</SPAN>
Dim PremDisbNum As Integer</SPAN>
Dim PremResNum As Integer</SPAN>
Dim PremAppControlandBalNum As Integer</SPAN>
Dim AgtCompensationNum As Integer</SPAN>
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''</SPAN>
QA = "Quality Assurance WQA DB 2012.xlsm"</SPAN>
Foremost = "Foremost WQA DB 2012.xlsm"</SPAN>
PremDisb = "Premium Disbursements WQA DB 2012.xlsm"</SPAN>
PremRes = "Premium Resolution WQA DB 2012.xlsm"</SPAN>
PremAppControlandBal = "Premium Application Control and Balancing WQA DB 2012.xlsm"</SPAN>
FinReporting1 = "Financial Reporting 1 WQA DB 2012.xlsm"</SPAN>
FinReporting2 = "Financial Reporting 2 WQA DB 2012.xlsm"</SPAN>
AgtCompensation = "Agent Compensation Team WQA DB 2012.xlsm"</SPAN>
Directory = "\\pafnp0628\Accounting\00000 Management Reports\QA Reviews\2012\"</SPAN>
'''''''''''''''''''''''''''''''''''''''
Here is where I need it to see if the QA file is open (Directory & QA) If it is then the message box and on the next file.
Workbooks.Open Directory & QA</SPAN></SPAN>
Workbooks(QA).Activate</SPAN>
Sheets("Database").Select</SPAN>
Application.Run ("DisplayAllQuestions")</SPAN>
Application.Run ("Unprotect")</SPAN>
Application.Run ("UnhideColumns")</SPAN>
Range("A46:Ab46").Select</SPAN>
Range("ab46").Activate</SPAN>
Selection.AutoFilter</SPAN>
Selection.AutoFilter</SPAN>
Selection.AutoFilter Field:=23, Criteria1:="1"</SPAN>
Selection.AutoFilter Field:=28, Criteria1:="="</SPAN>
Range("a47:AA47").Select</SPAN>
Range(Selection, Selection.End(xlDown)).Select</SPAN>
Selection.Copy</SPAN>
Workbooks("WQA Upload.xlsm").Activate</SPAN>
Range("A25").Select</SPAN>
If ActiveCell = "" Then</SPAN>
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _</SPAN>
:=False, Transpose:=False</SPAN>
Else</SPAN>
Selection.End(xlDown).Select</SPAN>
ActiveCell.Offset(1, 0).Select</SPAN>
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _</SPAN>
:=False, Transpose:=False</SPAN>
End If</SPAN>
Workbooks(QA).Activate</SPAN>
Selection.AutoFilter Field:=23</SPAN>
Selection.AutoFilter Field:=28</SPAN>
Range("AB47").Select</SPAN>
ActiveCell.End(xlDown).Select</SPAN>
ActiveCell.Offset(1, 0).Select</SPAN>
Do While ActiveCell.Value <> ""</SPAN>
ActiveCell.Offset(1, 0).Select</SPAN>
Loop</SPAN>
Do Until IsEmpty(ActiveCell.Offset(0, -5))</SPAN>
If ActiveCell.Offset(0, -5) = "1" And ActiveCell = "" Then</SPAN>
ActiveCell.Formula = "=""Uploaded on ""&TEXT(TODAY(),""MM/DD/YY"")"</SPAN>
ActiveCell.Offset(1, 0).Select</SPAN>
ElseIf ActiveCell.Offset(0, -5) = "0" Then</SPAN>
ActiveCell = ""</SPAN>
ActiveCell.Offset(1, 0).Select</SPAN>
Else</SPAN>
ActiveCell.Offset(1, 0).Select</SPAN>
End If</SPAN>
Loop</SPAN>
Application.Run ("RehideColumns")</SPAN>
Range("A47").Select</SPAN>
Workbooks(QA).Save</SPAN>
Workbooks(QA).Close</SPAN>
Workbooks("WQA Upload.xlsm").Activate</SPAN>
Workbooks("WQA Upload.xlsm").Save</SPAN>
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''</SPAN>
This is the next file to test (Directory & Foremost) If it is then the message box and on the next file.
Workbooks.Open Directory & Foremost</SPAN></SPAN>
Workbooks(Foremost).Activate</SPAN>
Sheets("Database").Select</SPAN>
Application.Run ("DisplayAllQuestions")</SPAN>
Application.Run ("Unprotect")</SPAN>
Application.Run ("UnhideColumns")</SPAN>
Range("A31:Ab31").Select</SPAN>
Range("ab31").Activate</SPAN>
Selection.AutoFilter</SPAN>
Selection.AutoFilter</SPAN>
Selection.AutoFilter Field:=23, Criteria1:="1"</SPAN>
Selection.AutoFilter Field:=28, Criteria1:="="</SPAN>
Range("a32:AA32").Select</SPAN>
Range(Selection, Selection.End(xlDown)).Select</SPAN>
Selection.Copy</SPAN>
Workbooks("WQA Upload.xlsm").Activate</SPAN>
Range("A25").Select</SPAN>
If ActiveCell = "" Then</SPAN>
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _</SPAN>
:=False, Transpose:=False</SPAN>
Else</SPAN>
Selection.End(xlDown).Select</SPAN>
ActiveCell.Offset(1, 0).Select</SPAN>
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _</SPAN>
:=False, Transpose:=False</SPAN>
End If</SPAN>
Workbooks(Foremost).Activate</SPAN>
Selection.AutoFilter Field:=23</SPAN>
Selection.AutoFilter Field:=28</SPAN>
Range("AB32").Select</SPAN>
ActiveCell.End(xlDown).Select</SPAN>
ActiveCell.Offset(1, 0).Select</SPAN>
Do While ActiveCell.Value <> ""</SPAN>
ActiveCell.Offset(1, 0).Select</SPAN>
Loop</SPAN>
Do Until IsEmpty(ActiveCell.Offset(0, -5))</SPAN>
If ActiveCell.Offset(0, -5) = "1" And ActiveCell = "" Then</SPAN>
ActiveCell.Formula = "=""Uploaded on ""&TEXT(TODAY(),""MM/DD/YY"")"</SPAN>
ActiveCell.Offset(1, 0).Select</SPAN>
ElseIf ActiveCell.Offset(0, -5) = "0" Then</SPAN>
ActiveCell = ""</SPAN>
ActiveCell.Offset(1, 0).Select</SPAN>
Else</SPAN>
ActiveCell.Offset(1, 0).Select</SPAN>
End If</SPAN>
Loop</SPAN>
Application.Run ("RehideColumns")</SPAN>
Range("A32").Select</SPAN>
Workbooks(Foremost).Save</SPAN>
Workbooks(Foremost).Close</SPAN>
Workbooks("WQA Upload.xlsm").Activate</SPAN>
Workbooks("WQA Upload.xlsm").Save</SPAN>
''''''''''''''''''''''''''''''''''''</SPAN>
There's more to this macro, but there's like 7 files I open and its pages long. So above it the jist of the code.