NascarBaritone
Registered User.
- Local time
- Today, 16:13
- Joined
- Sep 23, 2008
- Messages
- 75
I have a worksheet that I open from a batch file that then runs some processes. Here is the process.
Step 1:
User runs batch file which opens workbook with this On Open.
Step 2:
UserForm has a couple of textboxes that let the user select dates for a report. They then hit a button with this code:
Step 3:
Theoretically, UserForm3 should open with this on it's Initialize:
Step 4:
Macro1 should run with the following code:
Long story short...it makes it through everything fine, but for some reason, UserForm3 never shows up. UserForm3 is a "Report loading..." FYI userform that is there just so the user knows that something is actually happening.
Any suggestions?
Step 1:
User runs batch file which opens workbook with this On Open.
Code:
Private Sub Workbook_Open()
If Workbooks.Count > 2 Then
MsgBox "Please close all other Excel documents before running reports.", vbInformation + vbOKOnly, "Close Excel Documents"
ActiveWorkbook.Close
Else
Application.Visible = False
UserForm.Show
End If
End Sub
Step 2:
UserForm has a couple of textboxes that let the user select dates for a report. They then hit a button with this code:
Code:
Private Sub cmdStart_Click()
If Me.StartDate.Value = "" And Me.EndDate.Value = "" Then
MsgBox "Please enter a start and end date.", vbInformation + vbOKOnly, "Enter Start and End Dates"
Me.StartDate.SetFocus
ElseIf Me.StartDate.Value = "" Then
MsgBox "Please enter a start date.", vbInformation + vbOKOnly, "Enter Start Date"
Me.StartDate.SetFocus
ElseIf Me.EndDate.Value = "" Then
MsgBox "Please enter an end date.", vbInformation + vbOKOnly, "Enter End Date"
Me.EndDate.SetFocus
ElseIf Me.EndDate.Value < Me.StartDate.Value Then
MsgBox "End Date is prior to State Date", vbInformation + vbOKOnly, "Incorrect Dates"
Me.StartDate.Value = ""
Me.EndDate.Value = ""
Me.StartDate.SetFocus
Else
UserForm3.Show
End If
End Sub
Step 3:
Theoretically, UserForm3 should open with this on it's Initialize:
Code:
Private Sub UserForm_Initialize()
Call Macro1
End Sub
Step 4:
Macro1 should run with the following code:
Code:
MC = "E"
UserForm.Hide
Workbooks.Open Filename:= _
"C:\Documents and Settings\L104KLB\Desktop\2011DailyDirect$$InLog.xls"
Worksheets(2).Activate
Range("A6:P50000").Select
Selection.Copy
Windows("Check Log Review Template.xls").Activate
ActiveSheet.Paste
Windows("2011DailyDirect$$InLog.xls").Activate
Worksheets(ActiveSheet.Index + 1).Select
Range("A6:P50000").Select
Selection.Copy
Windows("Check Log Review Template.xls").Activate
Range("E1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, -4).Select
ActiveSheet.Paste
Workbooks.Open Filename:= _
"C:\Documents and Settings\L104KLB\Desktop\DailyBrokerage$$InLog.xlsx"
Worksheets(Worksheets.Count).Activate
Range("A6:P50000").Select
Selection.Copy
Windows("Check Log Review Template.xls").Activate
Range("E1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, -4).Select
ActiveSheet.Paste
Windows("DailyBrokerage$$InLog.xlsx").Activate
Worksheets(ActiveSheet.Index - 1).Select
Range("A6:P50000").Select
Selection.Copy
Windows("Check Log Review Template.xls").Activate
Range("E1").Select
Selection.End(xlDown).Select
ActiveCell.Offset(1, -4).Select
ActiveSheet.Paste
Range("A1").Select
Application.CutCopyMode = False
Selection.AutoFilter
ActiveSheet.Range("$A$2:$P$50000").AutoFilter Field:=5, Criteria1:= _
">=" & UserForm.StartDate.Value, Operator:=xlAnd, Criteria2:="<=" & UserForm.EndDate.Value
Range("A1:P50000").Select
Selection.Copy
Sheets.Add After:=Sheets(Sheets.Count)
ActiveSheet.Paste
Cells.Select
Cells.EntireColumn.AutoFit
Sheets("Sheet1").Select
Application.CutCopyMode = False
Application.DisplayAlerts = False
ActiveWindow.SelectedSheets.Delete
Workbooks("2011DailyDirect$$InLog.xls").Close savechanges:=False
ActiveWorkbook.SaveAs Filename:="K:\Corporate Compliance\EQSALES\COMPLIANCE\Check Log Reporter\Temp Check Log Report" & ".csv", _
FileFormat:=xlCSV, CreateBackup:=False
Call OpenAccess
Long story short...it makes it through everything fine, but for some reason, UserForm3 never shows up. UserForm3 is a "Report loading..." FYI userform that is there just so the user knows that something is actually happening.
Any suggestions?