i want to print an excel form from vb6 .. but ( i want to perview first ) and i want it in landscape
vb6+excelPrinting
Page 1 of 1
5 Replies - 1640 Views - Last Post: 10 April 2010 - 09:14 AM
Replies To: vb6+excel
#2
Re: vb6+excel
Posted 08 April 2010 - 05:32 PM
Sorry but we can not give you the entire code to solve your problem. We are here to assist in solving problems with code you have written, with any error messages you are getting or what isn't working the way that you expect it to, we would be more than happy to help you with those problems. If there is a topic that you don't understand we would be more than happy to help you with that as well. Make sure to post any code with in code tags like below.
Be sure to visit our tutorial and snippet areas or read the FAQS at the top of the forums. Also, take a moment to read the rules about posting topics.
Thank you for helping us to help you solve your problem.
Be sure to visit our tutorial and snippet areas or read the FAQS at the top of the forums. Also, take a moment to read the rules about posting topics.
Thank you for helping us to help you solve your problem.
#3
Re: vb6+excel
Posted 08 April 2010 - 09:32 PM
Private Sub cmdexcel_Click()
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
Dim DataArray(1 To 500, 1 To 5) As Variant
Dim r As Integer
Dim NumberOfRows As Integer
NumberOfRows = Adodc1.Recordset.RecordCount
Adodc1.Recordset.MoveFirst
For r = 1 To NumberOfRows
DataArray(r, 1) = Adodc1.Recordset.Fields("Id")
DataArray(r, 2) = Adodc1.Recordset.Fields("Date")
DataArray(r, 3) = Adodc1.Recordset.Fields("address")
DataArray(r, 4) = Adodc1.Recordset.Fields("Work")
DataArray(r, 5) = Adodc1.Recordset.Fields("Details")
Adodc1.Recordset.MoveNext
Next
Set oSheet = oBook.Worksheets(1)
oSheet.Range("A1:E1").Font.Bold = True
oSheet.Range("A1 :E1").Value = Array("ID", "Date", "address", "work", "Details")
oSheet.Range("A2").Resize(NumberOfRows, 5).Value = DataArray
oBook.SaveAs "C:\Activity.xls"
oExcel.Quit
Adodc1.Recordset.MoveFirst
MsgBox "Daily Progress Report File Saved", 64, "Info"
End Sub
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
Dim DataArray(1 To 500, 1 To 5) As Variant
Dim r As Integer
Dim NumberOfRows As Integer
NumberOfRows = Adodc1.Recordset.RecordCount
Adodc1.Recordset.MoveFirst
For r = 1 To NumberOfRows
DataArray(r, 1) = Adodc1.Recordset.Fields("Id")
DataArray(r, 2) = Adodc1.Recordset.Fields("Date")
DataArray(r, 3) = Adodc1.Recordset.Fields("address")
DataArray(r, 4) = Adodc1.Recordset.Fields("Work")
DataArray(r, 5) = Adodc1.Recordset.Fields("Details")
Adodc1.Recordset.MoveNext
Next
Set oSheet = oBook.Worksheets(1)
oSheet.Range("A1:E1").Font.Bold = True
oSheet.Range("A1 :E1").Value = Array("ID", "Date", "address", "work", "Details")
oSheet.Range("A2").Resize(NumberOfRows, 5).Value = DataArray
oBook.SaveAs "C:\Activity.xls"
oExcel.Quit
Adodc1.Recordset.MoveFirst
MsgBox "Daily Progress Report File Saved", 64, "Info"
End Sub
#4
Re: vb6+excel
Posted 09 April 2010 - 12:59 AM
#5 Guest_evry1falls*
Re: vb6+excel
Posted 10 April 2010 - 07:48 AM
i don't see any printing methods in those replies , weren't i clear ???
i realy know all this ,,, but my problems is in PrintOut (method) === i want the vbp to display the (page preview) b4 printing
i realy know all this ,,, but my problems is in PrintOut (method) === i want the vbp to display the (page preview) b4 printing
#6
Re: vb6+excel
Posted 10 April 2010 - 09:14 AM
here is how you do it
Dim XcLApp As Object
Dim XcLWB As Object
Dim XcLWS As Object
Set XcLApp = CreateObject("Excel.Application")
Set XcLWB = XcLApp.Workbooks.Add
Set XcLWS = XcLWB.Worksheets.Add
XcLWS.Range(Addres_Excel(1, 1)).Value = "Test string"
'optional if you set it to false it will just print the sheet out'
XcLApp.Visible = True
XcLWS.PrintOut
This post has been edited by NoBrain: 10 April 2010 - 09:20 AM
Page 1 of 1
|
|

New Topic/Question
Reply
MultiQuote






|