5 Replies - 2393 Views - Last Post: 10 April 2010 - 09:14 AM Rate Topic: -----

#1 Guest_evry1falls*


Reputation:

vb6+excel

Posted 08 April 2010 - 05:30 PM

i want to print an excel form from vb6 .. but ( i want to perview first ) and i want it in landscape
Is This A Good Question/Topic? 0

Replies To: vb6+excel

#2 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1641
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

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.

:code:

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.
Was This Post Helpful? 0
  • +
  • -

#3 ram11  Icon User is offline

  • D.I.C Head

Reputation: 4
  • View blog
  • Posts: 86
  • Joined: 30-November 08

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
Was This Post Helpful? 0
  • +
  • -

#4 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

Re: vb6+excel

Posted 09 April 2010 - 12:59 AM

or
http://www.dreaminco...xcel-using-vb6/

http://www.dreaminco...o-excel-in-vb6/

good luck :P
Was This Post Helpful? 0
  • +
  • -

#5 Guest_evry1falls*


Reputation:

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
Was This Post Helpful? 0

#6 raziel_  Icon User is offline

  • Like a lollipop
  • member icon

Reputation: 464
  • View blog
  • Posts: 4,255
  • Joined: 25-March 09

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

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1