473,382 Members | 1,107 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

Problem Exporting to Excel

121 100+
I am having quite the unique problem trying to Export to Excel and I need ot find a solution within 3 hours. -- PLEASE HELP!

The system exports a file from the application that the users can make changes to and then reimport. But now matter what format I specify to export to, when I open the exported files, it says they are in Excel 5.0.

I originally used the code:

Expand|Select|Wrap|Line Numbers
  1.         DoCmd.OutputTo acTable, "PRC_REPRT", "MicrosoftExcelBiff8(*.xls)", EXP_FLDR & "Processed Records - " & DATE_CODE & ".xls", False, "", 0
Doing a little research, I found a lot of people said that the "OutputTo" causes the problem and that I should use the "Transferspreadsheet" Command.

Now the code looks like this:
Expand|Select|Wrap|Line Numbers
  1.         DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "ERR_REPRT", EXP_FLDR & "Error Records - " & DATE_CODE & ".xls", False, , 0
The file exports in the right format, but it left me with a new problem. When I used the OutputTo command, It output with the Caption titles and they were formatted in Grey. It looked nice and i built my reimport mappings based on those titles. To change it now would be a huge undertaking.

So my question is, can I get the transferspreadsheet method to output the caption names not the actual field names (i.e "Serial Code" instead of "SERL_CD")


Thanks to anyone with some ideas or helpful hints!
May 14 '07 #1
3 4302
maxamis4
295 Expert 100+
The simple answer now. This method is used to export raw data, its quick neat but ineffictive for what you want.

What you want is something like this

Expand|Select|Wrap|Line Numbers
  1. Public objapp As Excel.Application
  2. Public objbook As Excel.Workbook
  3. Public objsheet As Excel.Worksheet
  4.  
  5. Set objbook = Workbooks.Add(Template:=CurrentProject.Path & "\Reservation List.xlt")  'Your excel spreadsheet file goes here
  6.                 Set objapp = objbook.Parent
  7.                     Set objsheet = objbook.Worksheets("sheet1") 'Name of sheet you want to export to
  8.                        objbook.Windows(1).Visible = True
  9.                          sSQL = "SELECT tbl_z_tempDID.DID, tbl_Order_Number_Arch_sub.ISDN_ckt_Id, tbl_Order_Number_Arch_sub.VerizonBTN, tbl_Order_Number_Arch_sub.SDP_Address, [tbl_Order_Number_Arch_sub]![Circuit_ID1] & ' - ' & Right([tbl_Order_Number_Arch_sub]![Circuit_ID2],4) AS MCI_CircuitID, tbl_Order_Number_Arch_sub.[MCI BTN], tbl_Order_Number_Arch_sub.Switch, tbl_Order_Number_Arch_sub.Comments" _
  10.                                     & " FROM tbl_Order_Number_Arch_sub INNER JOIN tbl_z_tempDID ON tbl_Order_Number_Arch_sub.AutoNumber = tbl_z_tempDID.DIDReference" _
  11.                                     & " WHERE (((tbl_Order_Number_Arch_sub.Carrier_OrderNumber)='" & Carrier_OrderNumber & "'))" _
  12.                                     & " ORDER BY tbl_z_tempDID.DID"
  13.                                 Set rs = db.OpenRecordset(sSQL)
  14.  
  15.                                 With objsheet
  16.                                     .Select
  17.                                         .Range("B3") = Carrier_OrderNumber
  18.                                             .Range("B4") = OrderDate
  19.                                                 .Range("B5") = rs!Did
  20.                                                     If lbl_description.Caption = " DID" Then
  21.                                                     .Range("B6") = "N/A"
  22.                                                          .Range("B7") = "N/A"
  23.                                                             .Range("B8") = "N/A"
  24.                                                      Else
  25.                                                     .Range("B6") = Forms!frm_Order_Req!frm_Order_Req_Address!Address
  26.                                                         .Range("B7") = SiteReference
  27.                                                             .Range("B8") = CrossAtSite
  28.  
  29.                                                     End If
  30.                                                                 .Range("B10") = RSD
  31.                                                                     .Range("A13").CopyFromRecordset rs
  32.                                                                         .Range("B13").CopyFromRecordset rs!SDN_ckt_Id
  33.                                 End With
  34.                                    '.Range("E1") = Now()
  35.                                 objapp.Visible = True
  36.  

With this one you create a template with all the nice trimmings you want and using the with function you can export to specific cells in excel
I am having quite the unique problem trying to Export to Excel and I need ot find a solution within 3 hours. -- PLEASE HELP!

The system exports a file from the application that the users can make changes to and then reimport. But now matter what format I specify to export to, when I open the exported files, it says they are in Excel 5.0.

I originally used the code:

Expand|Select|Wrap|Line Numbers
  1.         DoCmd.OutputTo acTable, "PRC_REPRT", "MicrosoftExcelBiff8(*.xls)", EXP_FLDR & "Processed Records - " & DATE_CODE & ".xls", False, "", 0
Doing a little research, I found a lot of people said that the "OutputTo" causes the problem and that I should use the "Transferspreadsheet" Command.

Now the code looks like this:
Expand|Select|Wrap|Line Numbers
  1.         DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "ERR_REPRT", EXP_FLDR & "Error Records - " & DATE_CODE & ".xls", False, , 0
The file exports in the right format, but it left me with a new problem. When I used the OutputTo command, It output with the Caption titles and they were formatted in Grey. It looked nice and i built my reimport mappings based on those titles. To change it now would be a huge undertaking.

So my question is, can I get the transferspreadsheet method to output the caption names not the actual field names (i.e "Serial Code" instead of "SERL_CD")


Thanks to anyone with some ideas or helpful hints!
May 14 '07 #2
JHNielson
121 100+
Is there a simpler way than this? I have over 110 columns I would have to map.

If this is the only way, I will do it, but I was hoping there might be an easier way...
May 14 '07 #3
It is too late ,But I suggest to use an c# excel component, I use it from last year, there may be a easier way to you.
Aug 18 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: sridevi | last post by:
Hello How to export data from ms-access database to excel worksheet using ASP. mainly i need to export data to multiple worksheets. it is very urgent to us. i have a sample code which works...
4
by: D | last post by:
I've created a report with many subreports of aggregate data. I want my client to be able to export this data to Excel to make her charts, etc. Only one problem: one of the fields is a "SchoolYear"...
2
by: G | last post by:
When I export data from access to excel by with "export" or "Analyze with" I seem to loose parts of some fields (long text strings). Is there a way to export it all to excel? Thanks G
2
by: Kenneth | last post by:
How do I remove the limitation in Access that deny me from exporting 24000 rows and 17 columns (in a query) into Excel? Kenneth
1
by: NancyA | last post by:
I am using the following code to write data from a datagrid to an Excel file: Dim tw As New System.IO.StringWriter Dim hw As New System.Web.UI.HtmlTextWriter(tw) dg.RenderControl(hw)...
2
by: Mustufa Baig | last post by:
Hi everybody, I have an ASP.NET website where clients can view their monthly billings by selecting different options. One of the option is the way they want to see the report i.e. whether they...
1
by: Mustufa Baig | last post by:
I have an ASP.NET website where I am showing off crystal reports to users by exporting them to pdf format. Following is the code: ---------------- 1 Private Sub ExportReport() 2 Dim oStream...
2
by: bienwell | last post by:
Hi, I have a question about exporting data from datagrid control into Excel file in ASP.NET. On my Web page, I have a linkbutton "Export data". This link will call a Sub Function to perform...
2
by: Snozz | last post by:
The short of it: If you needed to import a CSV file of a certain structure on a regular basis(say 32 csv files, each to one a table in 32 databases), what would be your first instinct on how to...
4
by: Tom | last post by:
I have a gridview on all of my web pages in my web app and they all export to excel. I have one page where the gridview is binding to a datatable that i created and only the first column is...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.