<%
Option Explicit
Dim MyWord
Dim Path2File
Dim Path2File1
if not isempty(Request.Form("Submit")) then
  set MyWord = Server.Createobject("Word.Application")
  MyWord.Application.Documents.Open Server.MapPath("../") _
    & "\balancedue.doc"
  MyWord.ActiveWindow.Selection.GoTo -1,,, "CurrentDate"
  MyWord.ActiveWindow.Selection.TypeText cstr(Date)
  MyWord.ActiveWindow.Selection.GoTo -1,,, "CustomersName"
  MyWord.ActiveWindow.Selection.TypeText cstr(Request.Form
    ("CustomersName"))
  MyWord.ActiveWindow.Selection.GoTo -1,,, "CustomersAddress"
  MyWord.ActiveWindow.Selection.TypeText cstr(Request.Form
    ("CustomersAddress"))
  MyWord.ActiveWindow.Selection.GoTo -1,,, "CustomersCSZ"
  MyWord.ActiveWindow.Selection.TypeText cstr(Request.Form
    ("CustomersCSZ"))
  MyWord.ActiveWindow.Selection.GoTo -1,,, "FirstName"
  if instr(Request.Form("CustomersName"), " ") > 0 then
    MyWord.ActiveWindow.Selection.TypeText _
      cstr(left(Request.Form("CustomersName"),instr(Request.Form
        ("CustomersName"), " ")-1))
  else
    MyWord.ActiveWindow.Selection.TypeText cstr
     (Request.Form("CustomersName"))
  end if    
  MyWord.ActiveWindow.Selection.GoTo -1,,, "CurrentBalance"
  MyWord.ActiveWindow.Selection.TypeText cstr(Request.Form("CurrentBalance"))
  MyWord.ActiveWindow.Selection.GoTo -1,,, "YourName"
  MyWord.ActiveWindow.Selection.TypeText cstr(Request.Form("YourName"))
  Path2File1 = Month(Date) & Day(Date) & Year(Date) _
    & Hour(Time) & Minute(Time) & Second(Time) & ".doc"
  Path2File = Server.MapPath("./") & "\" & Path2File1
  MyWord.ActiveDocument.SaveAs Path2File
  set MyWord = Nothing
  Response.Redirect "./" & Path2File1
end if
%>
