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
Printable View
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
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
To counter the spam here are links to free resources:
https://gist.github.com/wqweto/4eb3ecee2961ec2f60bf -- can export only tabular data in .xls/.xlsx/.xlsb/.csv files
https://github.com/wqweto/Biff12Writer -- can export pictures, multiple sheets, text formatting, etc. in BIFF12 (.xlsb) files
cheers,
</wqw>
I know it's and old post, but if someone can help..
I'm using the first link from wqweto to export to excel an adodb recordset (https://gist.github.com/wqweto/4eb3ecee2961ec2f60bf -- can export only tabular data in .xls/.xlsx/.xlsb/.csv files)
It's working fine, I modified all the "stable" variables to this: [" & sTable & "], this way i can create table names with dots, and more chars.
But i have a problem when creating the destination recordset.
Here:
If I want to use a name of the field something llike "Cod. Postal" is not working due the "."Code:'--- dump source recordset
If Not rsSrc.BOF And Not rsSrc.EOF Then
rsSrc.MoveFirst
End If
Do While Not rsSrc.EOF
rsDest.AddNew
For Each oFld In rsSrc.Fields
rsDest.Fields(oFld.Name).Value = oFld.Value
Next
rsDest.Update
rsSrc.MoveNext
Loop
How can i change this line: rsDest.Fields(oFld.Name).Value = oFld.Value in order to accept the . and save the values? any Ideas?
Thanks for all
Edit:
I must check all possibilities but changing the name for the position it seems to be working fine, the code:
Code:Dim aa As Single
Do While Not rsSrc.EOF
rsDest.AddNew
aa = 0
For Each oFld In rsSrc.Fields
rsDest.Fields(aa).Value = oFld.Value
aa = aa + 1
Next
rsDest.Update
rsSrc.MoveNext
Loop
Yes, escaping Workbook name needs some more attention in the code. Currenly the procedure expects this name to be quoted from the caller, i.e. use "[Cod. Postal]" when calling WriteToExcel, not "Cod. Postal" for Workbook name but obv. this is cumbersome and error prone.
I have no idea what is the problem with field names though and why would these need quoting when accessing Fields collection. Using numeric indexes is a solution to a problem that should never happen.
Btw, Dim aa As Single is dubious -- better use Long.
cheers,
</wqw>
Thanks! did it with Long.