Community discussion forum
Visual Basic 6.0 - Exporting a DataReport to Microsoft Word
-
This thread is for discussions of 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
-
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
-
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.
-
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?
-
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> </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> </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> </td><td><b>Priority</b></td><td>" & _
Me.txtField(3) & _
"</td></tr><tr><td><b>Gender</b></td><td>" & _
Me.txtField(8) & _
"</td><td> </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> </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) = "", " ", Me.MSHFlexGrid1.TextMatrix(A, 2)) & _
"</td><td>" & Me.MSHFlexGrid1.TextMatrix(A, 3) & _
"</td><td align=center>" & IIf(Me.MSHFlexGrid1.TextMatrix(A, 5) = "", " ", Me.MSHFlexGrid1.TextMatrix(A, 5)) & _
"</td><td>" & IIf(Me.MSHFlexGrid1.TextMatrix(A, 4) = "", " ", Me.MSHFlexGrid1.TextMatrix(A, 4)) & _
"</td><td>" & IIf(Me.MSHFlexGrid1.TextMatrix(A, 6) = "", " ", 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 E1End 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 -
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
-
Why nor Mailmerge it?
-
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.
-
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
-
please help me how to make or what will be the SQL code for the ff: * monthly * weekly * daily * am shift * pm shift
-
Pllzzz help, i can;t find ADO data control in components in Project tab.........
!--removed tag--> -
You can use RAQ Report. With it, you can export report to Word, PDF, Excel, Html, Txt easily.
!--removed tag-->Post was edited on 31/08/2009 13:53:31 Report abuse -
To my mind one of the best tool for work with word files is-docx corrupt,because program helped me many times and has free status.At the end it can too help you and recover your damaged files in Microsoft Word format.
!--removed tag-->
Post a reply
Related articles
Quick links
Recent activity
- danfeiyan18 danfeiyan18 replied to Tips for Burning iTunes mov...
- Nina Luis replied to How to convert avi to vob w...
- Nina Luis replied to How to download and convert...
- Nina Luis replied to How to download and convert...
- Cain Brown replied to How to convert videos to iPhone?
- Cain Brown replied to How to convert videos to iPhone?
Enter your message below
Sign in or Join us (it's free).