Results 1 to 2 of 2

Thread: VB6: How to set margins when exporting to Excel or Word?

  1. #1

    Thread Starter
    Member
    Join Date
    Jun 2010
    Posts
    40

    VB6: How to set margins when exporting to Excel or Word?

    Since I can't manage to print in VB6 with high quality (with every code I try, the printing looks pixelated and grey)... I resolved to export:

    * via RichTextBox, to Microsoft Word
    (.SaveFile FileName, and then opening it in Word via Shell)
    * via SpreadSheet, to Microsoft Excel
    (.Export FileName, and then opening it in Excel via Shell)

    ...the thing is I don't know:
    a) how to set the margins
    b) how to tell Word and Excel to print automatically, without the user having to click "print"

    Does anyone knows how?
    Thanks.

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: VB6: How to set margins when exporting to Excel or Word?

    a, you would need to automate either excel or word, though you may be able to set the margins in the rtbox

    b, if you are automating either you can just use the appropriate printout method
    or you can use shellexecute for the filename, with the print verb, which will print the file with the default application
    i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
    Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next

    dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part

    come back and mark your original post as resolved if your problem is fixed
    pete

Tags for this Thread

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