Results 1 to 40 of 48

Thread: create excel file without excel installed in vb6.0

Threaded View

  1. #22
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,541

    Re: create excel file without excel installed in vb6.0

    A follow up to this post. Actually came upon a need to create an XLS format without having MS Office installed. In post #2 above a DAO example exists. Here is a similar example using ADO:
    Code:
    Sub Main()
    Dim cn As ADODB.Connection
    Dim rs As  ADODB.Recordset
    
    Set cn = New ADODB.Connection
    cn.ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0; data source=c:\test.xls; Extended Properties=""Excel 8.0;HDR=YES"""
    cn.Open 
    
    cn.Execute "Create Table Table1(field1 VARCHAR(255))"
    Set rs = New ADODB.RecordSet
    rs.Open "[Table1$]", cn, adOpenDynamic, adLockOptimistic, adCmdTable
    
    rs.AddNew
    rs.Fields(0).Value = "hello!"
    rs.Update
    rs.Close: cn.Close
    Set rs = Nothing
    Set cn = Nothing
    End Sub
    Apologize if any typos. And found one. Had a comma after the field name in Create Table clause. Removed it.
    Last edited by LaVolpe; Mar 19th, 2015 at 09:35 AM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

Tags for this Thread

Posting Permissions

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



Click Here to Expand Forum to Full Width