Posted on 1997-04-28
I have written some Visual Basic code in a module sheet of an Excel 7.0 workbook. Basically the code selects some data from the workbook then activates Word 7.0 before opening a document and inserting the data from the Excel workbook into it and then printing two (2) copies of the Word document - the problem is however only one copy of the document ever prints and I cannot work out why. Below is the code I have used:
Set Word7 = CreateObject("Word.Basic")
If Selection.Rows.Count <> 1 Or Selection.Columns.Count <> 256 Then
MsgBox "You have not made a valid selection! Please select the row " _
+ "which contains the data for the invoice you want to print." _
, 48, "Invalid Selection"
RowRef = Selection.Row
Variable1$ = Cells(RowRef, 1)
Variable2$ = Cells(RowRef, 2)
Answer = .MsgBox("Are you sure you want to print the invoice?", _
"Print Invoice", 36)
If Answer = -1 Then .FilePrint , , , , , , , "2"
AppActivate "Microsoft Excel"
Set Word7 = Nothing