Hi,
New user so sorry if anything isn't correct on my first post!
I am trying to print some data from a form to an Excel sheet rather than just to my printer. I want to create a new Excel sheet every time ideally from an existing template. Here is the code for printing normally, what do I need to do to make it print to Excel?
Any help greatly appreciated.
Regards
Phil
New user so sorry if anything isn't correct on my first post!
I am trying to print some data from a form to an Excel sheet rather than just to my printer. I want to create a new Excel sheet every time ideally from an existing template. Here is the code for printing normally, what do I need to do to make it print to Excel?
Any help greatly appreciated.
Regards
Phil
Code:
Private Sub Command6_Click()
For X = 0 To 32
If Label2(X).Caption = "Induction Harden" Then
Text3(X).Text = 0
End If
Next X
For X = 0 To 32
If Label2(X).Caption = "Caseharden" Then
Text3(X).Text = 0
End If
Next X
For X = 0 To 32
If Label2(X).Caption = "Sub Contract M/c" Then
Text3(X).Text = 0
End If
Next X
For X = 0 To 32
If Label2(X).Caption = "Normalise" Then
Text3(X).Text = 0
End If
Next X
For X = 0 To 32
If Label2(X).Caption = "Anneal" Then
Text3(X).Text = 0
End If
Next X
For X = 0 To 32
If Label2(X).Caption = "Stress Relieve" Then
Text3(X).Text = 0
End If
Next X
For X = 0 To 32
If Label2(X).Caption = "Harden and Temper" Then
Text3(X).Text = 0
End If
Next X
For X = 0 To 32
If Label2(X).Caption = "Tufftride" Then
Text3(X).Text = 0
End If
Next X
For X = 0 To 32
If Label2(X).Caption = "Stabilise" Then
Text3(X).Text = 0
End If
Next X
For X = 0 To 32
If Label2(X).Caption = "Gas Nitride" Then
Text3(X).Text = 0
End If
Next X
For X = 0 To 32
If Label2(X).Caption = "Plasma Nitride" Then
Text3(X).Text = 0
End If
Next X
Printer.FontSize = 12
Printer.FontBold = True
Printer.Print
Printer.Print Label11.Caption, QUOTENO.Text, Label12.Caption, QUOTEISS.Text
Printer.Print
Printer.Print Label13.Caption; " "; CUSTOMER.Text, " ", Label14.Caption; " "; PARTNO.Text; " "; Label15.Caption; PARTISS.Text,
Printer.Print
Printer.Print Label17.Caption; " "; Text11.Text
Printer.Print
Printer.Print Label16.Caption, QUANTITY.Text
Printer.FontSize = 8
Printer.FontBold = False
Printer.Print
Printer.Print " ", "Lab", "O/H", "M/c", "Set", "Tot M/c", "Eff", "Time", "Lab", "O/H", "Total"
Printer.Print " ", "Rate", "Rate", "Time", "Time", "Time", "%", "X Eff", "Cost", "Cost", "Cost"
For X = 0 To 32
If Check1(X) = 1 Then
Printer.Print "Operation done in China"
End If
Printer.Print Label2(X).Caption
Printer.Print " ", Text3(X).Text, Text4(X).Text, Text5(X).Text, Text6(X).Text, Text7(X).Text, Text8(X).Text, Text9(X).Text, Int((Val(Text10(X).Text)) * 100) / 100, Int((Val(Text22(X).Text)) * 100) / 100, Int((Val(Text23(X).Text)) * 100) / 100
If Text3(X).Text = "" Then
X = 32
End If
Next X
For Z = 0 To 7
Printer.Print Text13(Z).Text; " £"; Text31(Z).Text
Next Z
Printer.Print
Printer.Print Label31.Caption; Text24.Text, Text29.Text; "%", " ", " Approx Weight of Billet "; Int((Val(Text42.Text) * 100)) / 100; " Kgs"
Printer.Print Label30.Caption; Text21.Text, Text28.Text; "%"
Printer.Print Label29.Caption; Text20.Text, Text27.Text; "%", " ", " Approx Weight at Normalising "; Int((Val(Text37.Text) * 100)) / 100; " Kgs"
Printer.Print Label21.Caption; Text15.Text, Text26.Text; "%"
Printer.Print Label23.Caption; Text17.Text, Text25.Text; "%", " ", " Approx Weight at Casehardening "; Int((Val(Text36.Text) * 100)) / 100; " Kgs"
Printer.Print
Printer.Print " ", Label24.Caption; Int((Val(Text18.Text) * 100)) / 100
Printer.Print " ", Label25.Caption; Int((Val(Text14.Text) * 100)) / 100
Printer.Print " ", Label27.Caption; Text19.Text
Printer.Print " ", Label26.Caption; " "; Text16.Text; "%"
Printer.Print
Printer.Print " Total UK machining time is", Val(Text40.Text), "mins"
Printer.Print
Printer.Print " Total China machining time is", Val(Text41.Text), "mins"
Printer.Print
Printer.Print "TOOLING REQUIREMENTS"
Printer.Print
Printer.Print TOOLING.Text
Printer.EndDoc
End Sub