Members

Technology Zones

IBM Learning Center

Articles

Hosted By

MaximumASP

Info

[5371] Visual Basic 6.0 - Exporting a DataReport to Microsoft Word

Last post 07-21-2007 10:27 AM by muralimoorthi. 9 replies.
Page 1 of 1 (10 items)
Sort Posts: Previous Next
  • 01-01-1999 12:00 AM

    [5371] Visual Basic 6.0 - Exporting a DataReport to Microsoft Word

    • Post Points: 35
  • Advertisement

    • Red Gate Software

    Advertisement

    Want to boost your .NET application performance?

    Some developers always seem to write efficient and lightening-fast code. What is their secret? It’s ANTS Profiler. “We improved the performance of the application up to 10 times” Dan Ports, Intrigma.

    Try it for yourself now.

  • 06-01-2006 11:24 PM In reply to

    Re: [5371] Visual Basic 6.0 - Exporting a DataReport to Microsoft Word

    Thanks for this nice tutorial!

    I actually tried to do this example my selef but, I have reached to dead point coz I was not able know how to load the DataEnvironment.

    So please can you help me in this issue.

    P.S. I tried to find the "More ActiveX Designers" from the "Component" list but I didn't find it.

    Thanks once more for Developer Fusion's team for their valued efforts!!

     

    Best regards,

    Mahmoud Abu Baker

    • Post Points: 10
  • 06-04-2006 12:35 AM In reply to

    • John D.
    • Not Ranked
    • Joined on 02-11-2006
    • United States
    • Member
    • Points 245

    Re: [5371] Visual Basic 6.0 - Exporting a DataReport to Microsoft Word

    You can find "More ActiveX Designers" by going to the Project menu. You will see  "More ActiveX Designers" there. You can also find it here by: Go to your project window and right click as if your going to Add a new form, instead of choosing a form just select "More ActiveX Designers" and then Data Environment.

    Hope this helps.

    John

     

    Free Web Hosting
    • Post Points: 5
  • 01-08-2007 10:47 AM In reply to

    Re: [5371] Visual Basic 6.0 - Exporting a DataReport to Microsoft Word

    After designing the VB you can go for

    Project Menu

    Then References option and then Microsoft Word 11.0 Library

    Now you can write code for displaying it.

    • Post Points: 5
  • 01-08-2007 3:31 PM In reply to

    Re: [5371] Visual Basic 6.0 - Exporting a DataReport to Microsoft Word

    WHAT TO DO IF I WANT TO INCREASE THE PAGE LENGTH, LIKE I WANT TO TAKE THE PRINT OUT ON AN 132 Col. PAPER ON A PRINTER LIKE EPSON. HOW TO INCREASE THE PAGE SIZE BY PROGRAMMING OR TO GENERATE A REPORT ON 132 Col PAPER?
    • Post Points: 5
  • 01-09-2007 8:34 AM In reply to

    • Kassem
    • Top 150 Contributor
    • Joined on 10-03-2006
    • Fanatic Member
    • Points 1,315

    Re: [5371] Visual Basic 6.0 - Exporting a DataReport to Microsoft Word

    Hi,

    Using data reports in VB6 is a headache espically when it is a little more complex than the case we have here. Most of the time reports contains parent data in the header in addition to child sub form or grid. Personally I had a lot of problems trying to do it through VB6 data enviroment report so I came to a trick to use internet explorer or Excel as my printing utilities where I have prepared a template for excel in which I export my data to print it and close the object all in the background. Same for internet explorer but it doesn't need a template. It is very fast and reliable (faster and more reliable than crystal reports) but of course you will need to use some excel VBA and HTML. I have enclosed below the last examples I used this code in.

    HTML

    Private Sub cmdExport_Click()

        Dim A As Integer
        Dim s As Integer
        On Error GoTo E
       
        If Me.txtField(0) = "" Or Me.txtField(7) = "" Or Not Me.MSHFlexGrid1.Rows > 0 Then
       
            MsgBox "There is no result to Export", , "Export Failure"
       
        Else
       
            Dim str As String
           
            str = "<html><head></head><body><h1><b>Specialized Medical Center Hospital</b></h><h3><b>Tel. 4164000  Fax 4648493</b></h><br><br><br>" & _
            "<table><tr><td><b>Patient ID</b></td><td>" & _
            Me.txtField(7) & _
            "</td><td>&nbsp;&nbsp;&nbsp;</td><td><b>Register Date</b></td><td>" & _
            Me.txtField(1) & _
            "</td></tr><tr><td><b>Patient Name</b></td><td>" & _
            Me.txtField(5) & _
            "</td><td>&nbsp;&nbsp;&nbsp;</td><td><b>Register Time</b></td><td>" & _
            Me.txtField(2) & _
            "</td></tr><tr><td><b>Date of Birth</b></td><td>" & _
            Me.txtField(4) & _
            "</td><td>&nbsp;&nbsp;&nbsp;</td><td><b>Priority</b></td><td>" & _
            Me.txtField(3) & _
            "</td></tr><tr><td><b>Gender</b></td><td>" & _
            Me.txtField(8) & _
            "</td><td>&nbsp;&nbsp;&nbsp;</td><td><b>Doctor</b></td><td>" & _
            Me.txtField(9) & _
            "</td></tr><tr><td><b>Sample ID</b></td><td>" & _
            Me.txtField(0) & _
            "</td><td>&nbsp;&nbsp;&nbsp;</td><td><b>Specimen</b></td><td>" & _
            Me.txtField(6) & _
            "</td></tr></table><br><table border=1 width=650><tr height=33><td><b>Test Name</b></td><td><b>Result</b></td><td><b>Unit</b></td><td colspan=2><b>Reference Range</b></td><td><b>Result Date</b></td><td><b>Verified</b></td></tr>"
           
           
            For A = 0 To Me.MSHFlexGrid1.Rows - 1
           
                If ttype <> "limited" Or Me.MSHFlexGrid1.TextMatrix(A, 7) = "Verified" Then
               
                    str = str & "<tr height=42><td>" & Me.MSHFlexGrid1.TextMatrix(A, 1) & _
                    "</td><td>" & IIf(Me.MSHFlexGrid1.TextMatrix(A, 2) = "", "&nbsp;", Me.MSHFlexGrid1.TextMatrix(A, 2)) & _
                    "</td><td>" & Me.MSHFlexGrid1.TextMatrix(A, 3) & _
                    "</td><td align=center>" & IIf(Me.MSHFlexGrid1.TextMatrix(A, 5) = "", "&nbsp;", Me.MSHFlexGrid1.TextMatrix(A, 5)) & _
                    "</td><td>" & IIf(Me.MSHFlexGrid1.TextMatrix(A, 4) = "", "&nbsp;", Me.MSHFlexGrid1.TextMatrix(A, 4)) & _
                    "</td><td>" & IIf(Me.MSHFlexGrid1.TextMatrix(A, 6) = "", "&nbsp;", Me.MSHFlexGrid1.TextMatrix(A, 6)) & _
                    "</td><td>" & Me.MSHFlexGrid1.TextMatrix(A, 7) & "</td></tr>"
           
                End If
           
            Next
           
            str = str & "</table><br><br><h6 align=right>Exported On " & Now() & " by " & title & " " & fullname & "</h></p></body></html>"
           
            Dim Y As String
           
            Y = InputBox("What do you want to name your file", "File Naming", "MRN")
            Y = IIf(IsNull(Y), "MRN", Y)
            WriteTextFile "c:\" & Y & ".html", str
            MsgBox "Your file was saved as C:\" & Y & ".html", , "Save Confirmation"
           
        End If
       
    E1:
        Exit Sub
    E:
        MsgBox "There was an error exporting the data", , "Export Failure"
        On Error GoTo E1


































































    End Sub

     

    EXCEL

    Private Sub cmdPrint_Click()
       
        On Error GoTo E
       
        If Me.txtField(0) = "" Or Me.txtField(7) = "" Or Not Me.MSHFlexGrid1.Rows > 0 Then
       
            MsgBox "There is no result to print", , "Print Failure"
       
        Else
       
            Dim xl
            Dim xlsheet
            Dim xlwbook
            Set xl = CreateObject("Excel.Application")
           
            Dim A As Integer
            Dim s As Integer
           
            Set xlwbook = xl.Workbooks.Open("C:\Lab\report1.xls")
            Set xlsheet = xlwbook.Sheets.Item(1)
       
            With xlsheet
                .range("B10") = Me.txtField(0)
                .range("B11") = Me.txtField(7)
                .range("B12") = Me.txtField(5)
                .range("B13") = Me.txtField(4)
                .range("B14") = Me.txtField(8)
                .range("F10") = Me.txtField(1)
                .range("F11") = Me.txtField(2)
                .range("F12") = Me.txtField(3)
                .range("F13") = Me.txtField(9)
                .range("F14") = Me.txtField(6)
            End With
           
            x = 19
           
            For A = 0 To Me.MSHFlexGrid1.Rows - 1
           
            With xlsheet
               
                    If ttype <> "limited" Or Me.MSHFlexGrid1.TextMatrix(A, 7) = "Verified" Then
                   
                    .range("A" & x) = Me.MSHFlexGrid1.TextMatrix(A, 1)
                    .range("B" & x) = Me.MSHFlexGrid1.TextMatrix(A, 2)
                    .range("C" & x) = Me.MSHFlexGrid1.TextMatrix(A, 3)
                    .range("D" & x) = Me.MSHFlexGrid1.TextMatrix(A, 5)
                    .range("E" & x) = Me.MSHFlexGrid1.TextMatrix(A, 4)
                    .range("F" & x) = Me.MSHFlexGrid1.TextMatrix(A, 6)
                    .range("G" & x) = Me.MSHFlexGrid1.TextMatrix(A, 7)
                    x = x + 1
                   
                    End If
                   
                End With
           
            Next
           
            xlsheet.PrintOut
            xl.ActiveWorkbook.Close False, "C:\Lab\report1.xls"
            xl.Quit
            xl.Quit
            Set xl = Nothing
            Set xlwbook = Nothing
           
        End If
       
    E1:
        Exit Sub
    E:
        xl.ActiveWorkbook.Close False, "C:\Lab\report1.xls"
        xl.Quit
        xl.Quit
        Set xl = Nothing
        Set xlwbook = Nothing
        MsgBox "There was an error printing your report please contact your IT representative", , "Print Failure"
        On Error GoTo E1
       
        End Sub












































































    It is never about the number of languages you know, you either have the logic of programming or you don't.
    • Post Points: 10
  • 06-04-2007 2:41 AM In reply to

    • jireh
    • Top 500 Contributor
    • Joined on 06-04-2007
    • Philippines
    • Addicted Member
    • Points 485

    Re: [5371] Visual Basic 6.0 - Exporting a DataReport to Microsoft Word

    Hi.

    Can you help me about the data report... What I want to be is that I want the datareport scale that is in landscape form.. but when I tried to adjust the report width or its width properties it gives an error "Report width is larger than the paper width." Can you help solve that problem....

    thank you very much!

    jireh

    http://www.martin2k.co.uk/forums/index.php?showforum=4
    http://www.a1vbcode.com/vbforums/
    • Post Points: 5
  • 07-17-2007 2:42 PM In reply to

    • AlanW
    • Not Ranked
    • Joined on 07-06-2006
    • United Kingdom
    • New Member
    • Points 10

    Re: [5371] Visual Basic 6.0 - Exporting a DataReport to Microsoft Word

    Why nor Mailmerge it?

    • Post Points: 10
  • 07-17-2007 11:48 PM In reply to

    • jireh
    • Top 500 Contributor
    • Joined on 06-04-2007
    • Philippines
    • Addicted Member
    • Points 485

    Re: [5371] Visual Basic 6.0 - Exporting a DataReport to Microsoft Word

    Thanks but I have solved it now but I have another problem now, can we set the datareport into 1/2 page only? I mean like the 1/2 size of the short bond paper, I tried to use the reportwidth, the height, the printer.papersize but still don't work. the datareport is still in a one whole page.

    http://www.martin2k.co.uk/forums/index.php?showforum=4
    http://www.a1vbcode.com/vbforums/
    • Post Points: 5
  • 07-21-2007 10:27 AM In reply to

    coding to get Hex value of character based on Font to Display on LED

    Please Post the coding to get the hex Value of Character of Font which is given by the User to Display on the LED. Please Help me.

    I want that coding to interact with Font Hex Value

     

    Accept what ever comes which will be God's Gift-Murali Natarajan
    • Post Points: 5
Page 1 of 1 (10 items)