Page 1 of 4 123 ... LastLast
Results 1 to 15 of 59
  1. #1
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Richtext Formatting (VB6)

    As an example the file attached shows the output from our DOS system.

    The formatting all over the place and wondered if there is any way to bring the document back in line.
    How well would Rich Text cope with this ?

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Richtext Formatting (VB6)

    The invoice looks OK if you use a fixed-width font such as Courier New, but using a proportional font such as Times New Roman wreaks havoc with the alignment of the text and numbers.

    Are you planning on generating such invoices yourself, from your VB6 application? If so, consider using Automation to create a Word document using code. You'll have to do a lot of work, but you will be able to control the formatting completely.

  3. #3
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Richtext Formatting (VB6)

    Hans

    I've just found out the DOS system will print to DOC format, and the spacing is ok.

    What version of DOC format, I don't know.

    If I can manipulate this and add a graphic (Company Logo), this will answer our prayers !

    If you know of something along these lines, I would be greatful for any help.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Richtext Formatting (VB6)

    A doc file is probably either MS Word or RTF (rich text format). You can find out as follows:
    - Start Word.
    - Select Tools | Options...
    - Activate the General tab.
    - Make sure that "Confirm conversion at Open" is ticked.
    - Click OK.
    - Open the doc file.
    If the document opens directly, it is in a recent Word format. Otherwise, a Convert File dialog will come up, with the format Word has detected selected, for example Rich Text Format.

    If it can be opened in Word, it should be possible to use code to open the file in Word, and add the logo.

  5. #5
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Richtext Formatting (VB6)

    Hans
    The conversion dialog pops up.

    Does this mean I am restricted ?

    Graphics and logo's: Is it possible to create a template looking like our Letterheads with Logo, Company Info etc ?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Richtext Formatting (VB6)

    1. What is the format proposed by Word in the Convert File dialog?
    2. If you accept the format proposed by Word, does the file open correctly?
    3. Yes, you can create a Word template with your company logo etc.
    4. If you can open the invoice in Word, you could transfer its contents into a document based on your template.

  7. #7
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Richtext Formatting (VB6)

    Plain text is the item selected in the list.

    And yes it opens correctly.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Richtext Formatting (VB6)

    OK, so it is in fact a plain text file.

    You could do the following:
    1. Create the template with the company logo etc. The page header and/or footer are good places for this.
    2. Import the invoice manually - this is a test, it can be automated later:
    - Create a new document based on the template.
    - Select Insert | File...
    - Import the invoice generated by the DOS system.
    - Remove the superfluous empty paragraphs at the beginning and end.
    3. If the results are satisfactory, the above steps can be converted to code in your VB6 program. We'll help you with that, but see if it works manually first.

  9. #9
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Richtext Formatting (VB6)

    Ok

    That worked Ok other than adjusting margins etc.
    The File for import lies in L:MMPDFInvoice.doc

    Where do I start from here ?

    I'm thinking a VB form as a pop up.
    Possibly only one command is suffice to do the following:

    Create new Doc using the template
    Import the DOS version
    E:Mail To The Recipient ( I can do this through Mapi)

  10. #10
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Richtext Formatting (VB6)

    Edited by HansV to correct code.

    Dave, you can control Word from your VB application by setting a reference (in Project | References...) to the Microsoft Word 10.0 Object Library (10.0 is Word 2002, use 9.0 for Word 2000, or 11.0 for Word 2003, etc.)

    Here is some phantom code to create a doc, import the report, and save it. You can then use MAPI code to create an e-mail with the document as attachment:

    Dim oWord As New Word.Application
    Dim oDoc As Word.Document

    ' Substitute correct path and name of template
    Set oDoc = oWord.Documents.Add(Template:= "L:MMPDFCompany.dot")
    ' Import report
    oWord.Selection.InsertFile FileName:="L:MMPDFInvoice.doc"
    ' Remove superfluous empty paragraphs
    With oWord.Selection.Find
    .Text = "^p^p^p^p"
    .Replacement.Text = ""
    .Execute Replace:=wdReplaceAll
    End With
    ' Save and close the document
    oDoc.SaveAs FileName:="L:PDFInvoice2.doc"
    oDoc.Close SaveChanges:=wdDoNotSaveChanges
    Set oDoc = Nothing
    oWord.Quit
    Set oWord = Nothing

  11. #11
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Richtext Formatting (VB6)

    Error 429 ActiveX on the line:

    Set oDoc = oWord.Documents.Add(Template:= "L:MMPDFCompany.dot")

    I created the Company.dot doc and saved it to L:MMPDF

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Richtext Formatting (VB6)

    Hmm, I tested that part of the code. Does the problem persist if you restart your PC?

    Additions (for if you can create a document):
    - Add , ConfirmConversions:=False after the line starting with Set oDoc = ...
    - Insert a line .Wrap = True above the line starting with .Execute ...

  13. #13
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Richtext Formatting (VB6)

    Hmmmmmmmmmmmmm


    Hans

    Yes, problem is still there if the PC is started !!

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Richtext Formatting (VB6)

    I'm stumped then. This is standard Automation code.

  15. #15
    Silver Lounger
    Join Date
    Jun 2002
    Location
    Cheadle, Staffordshire
    Posts
    2,177
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Richtext Formatting (VB6)

    Hans

    Just messing with code, and this will open the Report.Doc:
    Notice the two backslashes after L: ??

    <pre>Private Sub Command2_Click()
    Dim WordObj As Word.Application
    Dim WordDoc As Word.Document

    Set WordObj = CreateObject("Word.Application")
    Set WordDoc = WordObj.Documents.Open("L:mmpdfreport.doc")
    WordObj.Visible = True


    Set WordObj = Nothing

    End Sub</pre>


    And this opens both of them:

    <pre> Set WordObj = CreateObject("Word.Application")
    Set WordDot = WordObj.Documents.Open("L:mmpdfcompany.dot")
    Set WordDoc = WordObj.Documents.Open("L:mmpdfreport.doc")
    WordObj.Visible = True</pre>


Page 1 of 4 123 ... LastLast

Posting Permissions

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