Results 1 to 4 of 4

Thread: Printing a Form

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Dec 2003
    Posts
    509

    Printing a Form

    I am trying to print a form.
    I have tried many things, but it keeps on crashing when i try to bring up the print dialog box.

    I would like to print the form-how can i do this by using the print dialog box?
    any help please

  2. #2
    Sleep mode
    Join Date
    Aug 2002
    Location
    RUH
    Posts
    8,083

  3. #3
    Fanatic Member VBCrazyCoder's Avatar
    Join Date
    Apr 2003
    Posts
    681
    If your form is based mainly on a dataset (in a datagrid), then you can pretty easily go the GDI+ route, just make a method that parses your datatable(s) and adds rows, columns. The only thing to watch out for is that you have to maintain your own page breaks (column, row states).

  4. #4
    Lively Member nokia8210's Avatar
    Join Date
    Dec 2002
    Location
    Coventry
    Posts
    92
    this is the code i used to print a letter through .net u need to make a template and insert boomarks where u want the information then save it to a directory then run this code it should work.

    this bit opens and prints the form

    Dim sPrecedentName As String = (your directory here)
    Dim docLetter As Word.DocumentClass
    Dim wrdSession As Word.ApplicationClass
    Dim i As Int32 = 0


    'Open Template
    wrdSession = CreateObject("Word.Application")
    wrdSession.Visible = False
    wrdSession.DisplayAlerts = Word.WdAlertLevel.wdAlertsMessageBox
    docLetter = wrdSession.Documents.Open(sPrecedentName, , True, False)

    'Populate
    Me.ImportBookmarks(docLetter, your parameter here)

    'Close Template
    wrdSession.ActiveDocument.PrintOut()

    While wrdSession.Application.BackgroundPrintingStatus > 0
    'Waiting for doc to print
    Application.DoEvents()
    End While

    'Close Document without saving
    docLetter.Close(False)
    wrdSession.Quit()

    this bit inputs the data into the form

    Dim bmBookmark As Word.Bookmark


    fill your dataset here

    With ur dataset
    For Each bmBookmark In docLetter.Bookmarks
    bmBookmark.Select()
    Select Case bmBookmark.Name

    Case " bookmark 1"
    docLetter.Application.Selection.TypeText(.Item(enter dataset column)

    Case "bookmark 2"
    same as above

    Case "bookmark 3"
    same as above

    Case "bookmark 4"
    same as above

    End Select
    Next

    you have to refence word aswell but this might help.

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