By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,491 Members | 879 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,491 IT Pros & Developers. It's quick & easy.

Need help with opening excel worksheets and text files

P: n/a
Hi friends

I need routines to create an excel file with worksheets for each
customer and a text file as well for each customer, first worksheet
would be a "Summary Report", here is the code that would get the data
for me I would appreciate if someone can add routines to create excel
and text files to it, the columns in text file need to be "|"
separated - thanks ever so much for all the help I have been getting
from this wonderful forum :

---Code---

If PostgreSQLADOConnection() Then

Dim objIdADO As ADODB.Recordset
dim objOrdAdo As ADODB.Recordset
Dim sqlStrID As String
Dim sqlStrOrders as string

Set oConn = CurrentProject.Connection
Set cn = cPostgreSQL

sqlStrID = "SELECT id FROM tblCustomers order by id"
Set objIdADO = cPostgreSQL.Execute(sqlStrID)

Do While Not objIdADO.EOF

'Here I need the code to open worksheets for each customer
id as the name and also a text file
'Then print some heading and adding some formatting to both
excel worksheet and text file

sqlStrOrders = "SELECT order_id, qty, unit_price, amount
FROM tblOrders WHERE customer_id = " & objIdADO("id")
Set objOrdAdo = cPostgreSQL.Execute(sqlStrOrders)

Do While Not objOrdADO.EOF

'Here I need the code to print orders recordset to
customers worksheet and textfile
'At the end of the reports sum of amount

objOrdADO.MoveNext
Loop

objIdADO.MoveNext
Loop
Set objIdADO = Nothing
Set objOrdADO = Nothing
Set cPostgreSQL = Nothing
End If

---Code---
Nov 12 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
mr****@hotmail.com (mr_ocp) wrote in message news:<7e**************************@posting.google. com>...
Hi friends

I need routines to create an excel file with worksheets for each
customer and a text file as well for each customer, first worksheet
would be a "Summary Report", here is the code that would get the data
for me I would appreciate if someone can add routines to create excel
and text files to it, the columns in text file need to be "|"
separated - thanks ever so much for all the help I have been getting
from this wonderful forum :


One thing you could do is transfer the recordset from Access directly
to Excel, and then save using automation maybe.

For writing the thing to a text file, see Open/Write/Close etc. You
could just walk the columns collection of the recordset for each
record and write that value to a string variable and just throw in
your delimiter between each column value.
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.