Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Can I print in landsacape in VB6???

mOskimOski Member Posts: 44
I'm trying to print in VB 6. I want to print in landscape, like the one in ms word but I don't know how... I have labelboxes in the form... I tried the "printform" command and when I printed, some part of the labelboxes wasn't printed. I don't know why it turned out like that.... I don't know if its margins or something else that made it like that...

(T_T)


Comments

  • rushenttrushentt Member Posts: 33
    You need to use VB's Printer object to be able to print within a program and set Printer.Orientation to cdlLandscape ie:
    Printer.Orientation = cdlLandscape

    Alternatively if you have Microsoft Word, you can automate Word and send all your output to word and have word print it for you from your program.

    Regards

    Terry

    : I'm trying to print in VB 6. I want to print in landscape, like the
    : one in ms word but I don't know how... I have labelboxes in the
    : form... I tried the "printform" command and when I printed, some
    : part of the labelboxes wasn't printed. I don't know why it turned
    : out like that.... I don't know if its margins or something else that
    : made it like that...
    :
    : (T_T)
    :
    :
    :
  • mOskimOski Member Posts: 44
    : You need to use VB's Printer object to be able to print within a
    : program and set Printer.Orientation to cdlLandscape ie:
    : Printer.Orientation = cdlLandscape
    :
    : Alternatively if you have Microsoft Word, you can automate Word and
    : send all your output to word and have word print it for you from
    : your program.
    :
    : Regards
    :
    : Terry
    :
    : : I'm trying to print in VB 6. I want to print in landscape, like the
    : : one in ms word but I don't know how... I have labelboxes in the
    : : form... I tried the "printform" command and when I printed, some
    : : part of the labelboxes wasn't printed. I don't know why it turned
    : : out like that.... I don't know if its margins or something else that
    : : made it like that...
    : :
    : : (T_T)
    : :
    : :
    : :
    :

    ummm... I don't know how to send all the outputs to ms word... T_T


  • rushenttrushentt Member Posts: 33
    You will need some thing like:- ......


    On the Project menu, click References,
    and select "Microsoft Word 8.0 Object Library" - Word 97 (or "Microsoft Word 9.0 Object Library" if you are using Word 2000). The Object library will depend on which version of Word that you are using. Later versions than Word 2000 will have a correspondly higher object library.

    From within your program:-

    1. Declare some variables to deal with word, here they are global:-
    '// Word automation
    Public gWord As Word.Application
    Public gDoc As Word.Document


    2. In a procedure or function:-
    Set gWord = CreateObject("Word.Application")
    Set gDoc = gWord.Documents.Open("MyFileName.Doc")

    Dim dlgFile As CommonDialog

    With gDoc

    ' Existing Document ...
    '// Add text to the document
    .Selection.TypeText Text:="one"
    .Selection.TypeParagraph
    .Selection.TypeText Text:="two"
    .Selection.TypeParagraph
    .Selection.TypeText Text:="three"
    'Save the document
    .Document.Save
    .Close

    End With


    '// Or create a new document
    With gWord

    '// Create a new document
    .Documents.Add

    'Add text to the document
    .Selection.TypeText Text:="one"
    .Selection.TypeParagraph
    .Selection.TypeText Text:="two"
    .Selection.TypeParagraph
    .Selection.TypeText Text:="three"
    'Save the document
    .ActiveDocument.SaveAs FileName:="c:Doc1.doc", _
    FileFormat:=wdFormatDocument, LockComments:=False, _
    Password:="", AddToRecentFiles:=True, WritePassword _
    :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
    SaveNativePictureFormat:=False, SaveFormsData:=False, _
    SaveAsAOCELetter:= False

    End With


    '// Send to printer
    With dlgFile
    .DialogTitle = "Print Document " & MyFileName.Doc
    .CancelError = True
    .Flags = cdlPDAllPages + cdlPDHidePrintToFile + cdlPDNoPageNums + cdlPDNoSelection
    .ShowPrinter
    End With



    '// Quit Word
    gWord.Quit




    : : You need to use VB's Printer object to be able to print within a
    : : program and set Printer.Orientation to cdlLandscape ie:
    : : Printer.Orientation = cdlLandscape
    : :
    : : Alternatively if you have Microsoft Word, you can automate Word and
    : : send all your output to word and have word print it for you from
    : : your program.
    : :
    : : Regards
    : :
    : : Terry
    : :
    : : : I'm trying to print in VB 6. I want to print in landscape, like the
    : : : one in ms word but I don't know how... I have labelboxes in the
    : : : form... I tried the "printform" command and when I printed, some
    : : : part of the labelboxes wasn't printed. I don't know why it turned
    : : : out like that.... I don't know if its margins or something else that
    : : : made it like that...
    : : :
    : : : (T_T)
    : : :
    : : :
    : : :
    : :
    :
    : ummm... I don't know how to send all the outputs to ms word... T_T
    :
    :
    :
  • mOskimOski Member Posts: 44
    : You will need some thing like:- ......
    :
    :
    : On the Project menu, click References,
    : and select "Microsoft Word 8.0 Object Library" - Word 97 (or
    : "Microsoft Word 9.0 Object Library" if you are using Word 2000). The
    : Object library will depend on which version of Word that you are
    : using. Later versions than Word 2000 will have a correspondly higher
    : object library.
    :
    : From within your program:-
    :
    : 1. Declare some variables to deal with word, here they are global:-
    : '// Word automation
    : Public gWord As Word.Application
    : Public gDoc As Word.Document
    :
    :
    : 2. In a procedure or function:-
    : Set gWord = CreateObject("Word.Application")
    : Set gDoc = gWord.Documents.Open("MyFileName.Doc")
    :
    : Dim dlgFile As CommonDialog
    :
    : With gDoc
    :
    : ' Existing Document ...
    : '// Add text to the document
    : .Selection.TypeText Text:="one"
    : .Selection.TypeParagraph
    : .Selection.TypeText Text:="two"
    : .Selection.TypeParagraph
    : .Selection.TypeText Text:="three"
    : 'Save the document
    : .Document.Save
    : .Close
    :
    : End With
    :
    :
    : '// Or create a new document
    : With gWord
    :
    : '// Create a new document
    : .Documents.Add
    :
    : 'Add text to the document
    : .Selection.TypeText Text:="one"
    : .Selection.TypeParagraph
    : .Selection.TypeText Text:="two"
    : .Selection.TypeParagraph
    : .Selection.TypeText Text:="three"
    : 'Save the document
    : .ActiveDocument.SaveAs FileName:="c:Doc1.doc", _
    : FileFormat:=wdFormatDocument, LockComments:=False, _
    : Password:="", AddToRecentFiles:=True, WritePassword _
    : :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
    : SaveNativePictureFormat:=False, SaveFormsData:=False, _
    : SaveAsAOCELetter:= False
    :
    : End With
    :
    :
    : '// Send to printer
    : With dlgFile
    : .DialogTitle = "Print Document " & MyFileName.Doc
    : .CancelError = True
    : .Flags = cdlPDAllPages + cdlPDHidePrintToFile + cdlPDNoPageNums
    : + cdlPDNoSelection
    : .ShowPrinter
    : End With
    :
    :
    :
    : '// Quit Word
    : gWord.Quit
    :
    :
    :
    :
    : : : You need to use VB's Printer object to be able to print within a
    : : : program and set Printer.Orientation to cdlLandscape ie:
    : : : Printer.Orientation = cdlLandscape
    : : :
    : : : Alternatively if you have Microsoft Word, you can automate Word and
    : : : send all your output to word and have word print it for you from
    : : : your program.
    : : :
    : : : Regards
    : : :
    : : : Terry
    : : :
    : : : : I'm trying to print in VB 6. I want to print in landscape, like the
    : : : : one in ms word but I don't know how... I have labelboxes in the
    : : : : form... I tried the "printform" command and when I printed, some
    : : : : part of the labelboxes wasn't printed. I don't know why it turned
    : : : : out like that.... I don't know if its margins or something else that
    : : : : made it like that...
    : : : :
    : : : : (T_T)
    : : : :
    : : : :
    : : : :
    : : :
    : :
    : : ummm... I don't know how to send all the outputs to ms word... T_T
    : :
    : :
    : :
    :


    thank you sooo much for the code! I really appreciate it!!! (^_^)


  • rushenttrushentt Member Posts: 33
    If you have any problems with the code, post a reply and I'll try to be a little bit more specific.

    Rgds

    Terry

    : : You will need some thing like:- ......
    : :
    : :
    : : On the Project menu, click References,
    : : and select "Microsoft Word 8.0 Object Library" - Word 97 (or
    : : "Microsoft Word 9.0 Object Library" if you are using Word 2000). The
    : : Object library will depend on which version of Word that you are
    : : using. Later versions than Word 2000 will have a correspondly higher
    : : object library.
    : :
    : : From within your program:-
    : :
    : : 1. Declare some variables to deal with word, here they are global:-
    : : '// Word automation
    : : Public gWord As Word.Application
    : : Public gDoc As Word.Document
    : :
    : :
    : : 2. In a procedure or function:-
    : : Set gWord = CreateObject("Word.Application")
    : : Set gDoc = gWord.Documents.Open("MyFileName.Doc")
    : :
    : : Dim dlgFile As CommonDialog
    : :
    : : With gDoc
    : :
    : : ' Existing Document ...
    : : '// Add text to the document
    : : .Selection.TypeText Text:="one"
    : : .Selection.TypeParagraph
    : : .Selection.TypeText Text:="two"
    : : .Selection.TypeParagraph
    : : .Selection.TypeText Text:="three"
    : : 'Save the document
    : : .Document.Save
    : : .Close
    : :
    : : End With
    : :
    : :
    : : '// Or create a new document
    : : With gWord
    : :
    : : '// Create a new document
    : : .Documents.Add
    : :
    : : 'Add text to the document
    : : .Selection.TypeText Text:="one"
    : : .Selection.TypeParagraph
    : : .Selection.TypeText Text:="two"
    : : .Selection.TypeParagraph
    : : .Selection.TypeText Text:="three"
    : : 'Save the document
    : : .ActiveDocument.SaveAs FileName:="c:Doc1.doc", _
    : : FileFormat:=wdFormatDocument, LockComments:=False, _
    : : Password:="", AddToRecentFiles:=True, WritePassword _
    : : :="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
    : : SaveNativePictureFormat:=False, SaveFormsData:=False, _
    : : SaveAsAOCELetter:= False
    : :
    : : End With
    : :
    : :
    : : '// Send to printer
    : : With dlgFile
    : : .DialogTitle = "Print Document " & MyFileName.Doc
    : : .CancelError = True
    : : .Flags = cdlPDAllPages + cdlPDHidePrintToFile + cdlPDNoPageNums
    : : + cdlPDNoSelection
    : : .ShowPrinter
    : : End With
    : :
    : :
    : :
    : : '// Quit Word
    : : gWord.Quit
    : :
    : :
    : :
    : :
    : : : : You need to use VB's Printer object to be able to print within a
    : : : : program and set Printer.Orientation to cdlLandscape ie:
    : : : : Printer.Orientation = cdlLandscape
    : : : :
    : : : : Alternatively if you have Microsoft Word, you can automate Word and
    : : : : send all your output to word and have word print it for you from
    : : : : your program.
    : : : :
    : : : : Regards
    : : : :
    : : : : Terry
    : : : :
    : : : : : I'm trying to print in VB 6. I want to print in landscape, like the
    : : : : : one in ms word but I don't know how... I have labelboxes in the
    : : : : : form... I tried the "printform" command and when I printed, some
    : : : : : part of the labelboxes wasn't printed. I don't know why it turned
    : : : : : out like that.... I don't know if its margins or something else that
    : : : : : made it like that...
    : : : : :
    : : : : : (T_T)
    : : : : :
    : : : : :
    : : : : :
    : : : :
    : : :
    : : : ummm... I don't know how to send all the outputs to ms word... T_T
    : : :
    : : :
    : : :
    : :
    :
    :
    : thank you sooo much for the code! I really appreciate it!!! (^_^)
    :
    :
    :
Sign In or Register to comment.