I have a macro that modifies an open document and creates a new document. The new document does not open.
Is there a way to just have the newly created document print right away? It does not need to be opened or saved, just printed.
Here is the code:
Sub YoYo()
Dim MyFile As Variant
Dim OutputFile As String
Dim count As Integer
Dim LineArray() As String
Dim MyLine As String
Dim arrNum As Long
Dim openfile As Long
Dim temp As String
On Error GoTo MyErrorHandler:
ReDim LineArray(10000000000#)
OutputFile = Mid$(CStr(ActiveDocument), 1, Len(ActiveDocument) - 3) & "doc"
Open ActiveDocument For Input As #1
Open OutputFile For Output As #2
Line Input #1, MyLine
While InStr(1, MyLine, "(") = 0
Print #2, MyLine
Line Input #1, MyLine
Wend
arrNum = 1
While Not EOF(1)
If InStr(1, MyLine, "(") <> 0 Then
Print #2, MyLine
For i = 1 To 30
Line Input #1, MyLine
Print #2, MyLine
Next i
For i = 1 To 6
Print #2,
Next i
Line Input #1, MyLine
Do Until InStr(1, MyLine, "(") <> 0
LineArray(arrNum) = MyLine
arrNum = arrNum + 1
Line Input #1, MyLine
Loop
If InStr(1, MyLine, "(") <> 0 Then
For i = 20 To 1 Step -1
Print #2, LineArray(arrNum - i)
Next i
End If
ReDim LineArray(10000000000#)
arrNum = 1
End If
Wend
Close #1
Close #2
UserForm1.Hide
MyErrorHandler:
If Err.number = 62 Then
Close #1
Close #2
UserForm1.Hide
Exit Sub
End If
End Sub
Is there a way to just have the newly created document print right away? It does not need to be opened or saved, just printed.
Here is the code:
Sub YoYo()
Dim MyFile As Variant
Dim OutputFile As String
Dim count As Integer
Dim LineArray() As String
Dim MyLine As String
Dim arrNum As Long
Dim openfile As Long
Dim temp As String
On Error GoTo MyErrorHandler:
ReDim LineArray(10000000000#)
OutputFile = Mid$(CStr(ActiveDocument), 1, Len(ActiveDocument) - 3) & "doc"
Open ActiveDocument For Input As #1
Open OutputFile For Output As #2
Line Input #1, MyLine
While InStr(1, MyLine, "(") = 0
Print #2, MyLine
Line Input #1, MyLine
Wend
arrNum = 1
While Not EOF(1)
If InStr(1, MyLine, "(") <> 0 Then
Print #2, MyLine
For i = 1 To 30
Line Input #1, MyLine
Print #2, MyLine
Next i
For i = 1 To 6
Print #2,
Next i
Line Input #1, MyLine
Do Until InStr(1, MyLine, "(") <> 0
LineArray(arrNum) = MyLine
arrNum = arrNum + 1
Line Input #1, MyLine
Loop
If InStr(1, MyLine, "(") <> 0 Then
For i = 20 To 1 Step -1
Print #2, LineArray(arrNum - i)
Next i
End If
ReDim LineArray(10000000000#)
arrNum = 1
End If
Wend
Close #1
Close #2
UserForm1.Hide
MyErrorHandler:
If Err.number = 62 Then
Close #1
Close #2
UserForm1.Hide
Exit Sub
End If
End Sub