dcsimg
Page 2 of 2 FirstFirst 12
Results 41 to 44 of 44
  1. #41
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    6,440

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

    Excellent....(rs.movefirst)...
    Thanks for all the work you did....I may never use this, but it ill sit in my bag in case.

    Sam

  2. #42
    Lively Member
    Join Date
    Apr 2014
    Location
    Munich, Germany
    Posts
    93

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

    Quote Originally Posted by LaVolpe View Post
    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
    Diggin' out an old thread ... it looks like this solution, as well as my DAO code in post #2, doesn't work anymore. They somehow broke it.

  3. #43
    PowerPoster
    Join Date
    Feb 2006
    Posts
    18,861

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

    Working fine here. Somewhat more elaborate example.
    Attached Files Attached Files

  4. #44
    Lively Member
    Join Date
    Apr 2014
    Location
    Munich, Germany
    Posts
    93

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

    Quote Originally Posted by dilettante View Post
    Working fine here. Somewhat more elaborate example.
    You're right, this works, thank you.

    However, did you try the examples in posts #2 and #30, too? These used to work as well, but they do not anymore (tested in Win7 and 8.1 so far). Creating the XLS file actually happens, but in the same step error 3274 occurs (something like "the external table does not have the expected format" - translated from German here).

    Anyway, your code shows that ADOX still does the job. Thanks for that.

    Wolfgang

Page 2 of 2 FirstFirst 12

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
  •  



Featured


Click Here to Expand Forum to Full Width


×
We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.