Results 1 to 3 of 3

Thread: How to close Word directly after Print command w/o getting prompted

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    In my code I print and ack letter. Everything works great, but after I print the document I need to Close Word and go back to program. When I close Word, I get prompted that if I close Word it will delete any pending print jobs; do I Want to close Word.

    Any ideas how to stall the close until the document is printed; here is the code.

    If cboLetter = "L" Then
    Dim obj As New Word.Application
    obj.WindowState = wdWindowStateMaximize
    obj.Visible = True
    obj.Documents.Open ("G:\WORD\TEMPLATE\Ombudsman\FSD.dot")
    obj.ActiveDocument.Select
    With Selection.ParagraphFormat
    .LeftIndent = InchesToPoints(0)
    .RightIndent = InchesToPoints(0)
    .SpaceBefore = 0
    .SpaceBeforeAuto = False
    .SpaceAfter = 0
    .SpaceAfterAuto = False
    .LineSpacingRule = wdLineSpaceSingle
    .Alignment = wdAlignParagraphJustify
    .WidowControl = True
    .KeepWithNext = False
    .KeepTogether = False
    .PageBreakBefore = False
    .NoLineNumber = False
    .Hyphenation = True
    .FirstLineIndent = InchesToPoints(0)
    .OutlineLevel = wdOutlineLevelBodyText
    .CharacterUnitLeftIndent = 0
    .CharacterUnitRightIndent = 0
    .CharacterUnitFirstLineIndent = 0
    .LineUnitBefore = 0
    .LineUnitAfter = 0
    End With

    With Selection.Font
    .Name = "Arial"
    .Size = 11
    .Bold = False
    .Italic = False
    .Underline = wdUnderlineNone
    .UnderlineColor = wdColorAutomatic
    .StrikeThrough = False
    .DoubleStrikeThrough = False
    .Outline = False
    .Emboss = False
    .Shadow = False
    .Hidden = False
    .SmallCaps = False
    .AllCaps = False
    .Color = wdColorAutomatic
    .Engrave = False
    .Superscript = False
    .Subscript = False
    .Spacing = 0
    .Scaling = 100
    .Position = 0
    .Kerning = 0
    .Animation = wdAnimationNone
    End With
    obj.Selection.InsertDateTime DateTimeFormat:="MMMM d, yyyy", InsertAsField:= _
    False, DateLanguage:=wdEnglishUS, CalendarType:=wdCalendarWestern, _
    InsertAsFullWidth:=False
    obj.Selection.TypeParagraph
    obj.Selection.TypeParagraph
    obj.Selection.TypeParagraph
    obj.Selection.TypeText txtFirstName & " " & txtLastName
    obj.Selection.TypeParagraph
    obj.Selection.TypeText txtAddress1
    obj.Selection.TypeParagraph
    obj.Selection.TypeText txtCity & ", " & txtState & " " & txtZip
    obj.Selection.TypeParagraph
    obj.Selection.TypeParagraph
    obj.Selection.TypeParagraph
    obj.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
    obj.Selection.TypeText "Re:" & " " & cboNo
    obj.Selection.TypeParagraph
    obj.Selection.TypeText "Response No.:" & " " & txtAutoResponse
    obj.Selection.TypeParagraph
    obj.Selection.TypeParagraph
    obj.Selection.TypeParagraph
    obj.Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
    obj.Selection.TypeText "Dear" & " " & txtFirstName & " " & txtLastName
    obj.Selection.TypeParagraph
    obj.Selection.TypeParagraph
    Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
    obj.Selection.TypeText "I have received your letter complaint dated" & " " & txtDateOpened & "." & _
    "Your letter has been forwarded to the attention of a Public Service Representative for investigation and response."
    obj.Selection.TypeParagraph
    obj.Selection.TypeParagraph
    Selection.ParagraphFormat.Alignment = wdAlignParagraphJustify
    obj.Selection.TypeText "Please be assured that the issues you raised in your letter will be fully investigated. Also, that you will receive a written reply within 30 days of the receipt of this letter."
    obj.Selection.TypeParagraph
    obj.Selection.TypeParagraph
    obj.Selection.TypeText "Very Truly Yours,"
    obj.Selection.TypeParagraph
    obj.Selection.TypeParagraph
    obj.Selection.TypeParagraph
    obj.Selection.TypeParagraph
    obj.Selection.TypeParagraph
    obj.Selection.TypeParagraph
    obj.Selection.TypeText "John Doe"
    obj.Selection.TypeParagraph
    obj.Selection.TypeText "Assistant Director, of Nothin"
    obj.ActiveDocument.PrintOut
    Close all open Word documents and exit Word
    obj.Documents.Close wdDoNotSaveChanges
    'obj.Application.Quit
    End If


    Thanks

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    The false statement worked great; how could i minimize word and print with the program still showing?

    Thank You!!!

  3. #3
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195
    WordApp.Application.WindowState = wdWindowStateMinimize

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width