Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating an Excel Workbook in Access/VBA - CSV to XLS conversion


The following is a copy of my post in AccessMonster, but I've had no
response there. I hope there is someone in this newsgroup with enough
familiarity with Access to give me a suggestion. When I open the
workbook resulting from this code, I have a single column with the
comma-seperated values in it, rather than a matrix of an equal number
of rows and columns.

"I am exporting queries to a 4 sheet XL workbook. The transfer
spreadsheet
method puts a ' in front of all of my numbers, necessitating a
formatting
procedure to remove them and properly format the fields. That's fine
when
there are a manageable number of cells to be formatted, but I have one
sheet
that has a matrix on the order of 175X175 cells that causes my
StripXLFormats
function (shamelessly pilfered from this newsgroup) to take upwards of
15
minutes to complete. This is unacceptable, so I'm trying to work around
the
problem with this one sheet by exporting it first, via TransferText to
a CSV
file, obviating the need to strip the ' from each cell and reformatting
cell
by cell. I then want to open it in Excel and save it as an Excel
workbook.
Then I can export the remaining 3 queries as Excel worksheets and
format them
as needed.

DoCmd.TransferText acExportDelim, , strQuery, strPath & strCSVFile,
True,
""
Set xlObj = CreateObject("excel.application")
With xlObj
Set WkBk = .Workbooks.Open(strPath & strCSVFile)
WkBk.SaveAs Filename:=strPath & strFile
Set WkSht = WkBk.ActiveSheet
WkSht.Name = strSheet
WkBk.Save
DoEvents
WkBk.Close SaveChanges:=True
DoEvents
DoCmd.SetWarnings True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"qryPEExport", strPath & strFile, True, "PEExport"
StripXLFormats strPath & strFile, "PEExport"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"qryCurveExp", strPath & strFile, True, "Curve"
StripXLFormats strPath & strFile, "Curve"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"qryPEFactorsExp", strPath & strFile, True, "PE_Factors"
StripXLFormats strPath & strFile, "PE_Factors"
Set WkBk = .Workbooks.Open(strPath & strFile)
Set WkSht = WkBk.Sheets(strSheet)
With WkSht
..Move after:=Worksheets("PE_Factors")
..Range("B2").Select
..Range(Selection, Selection.End(xlDown)).Select
..Range(Selection, Selection.End(xlToRight)).Select
Selection.Style = "Currency"
End With
Screen.MousePointer = 0
..Save
..Quit
End With"


--
ragtopcaddy
------------------------------------------------------------------------
ragtopcaddy's Profile: http://www.excelforum.com/member.php...o&userid=25838
View this thread: http://www.excelforum.com/showthread...hreadid=535577

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 96
Default Creating an Excel Workbook in Access/VBA - CSV to XLS conversion

The transfer spreadsheet method / action should not put ' in front of
numbers. It doesn't for me. Check the properties you are seting for that
method / action. You could also post on the Access newsgroup site.

"ragtopcaddy" wrote:


The following is a copy of my post in AccessMonster, but I've had no
response there. I hope there is someone in this newsgroup with enough
familiarity with Access to give me a suggestion. When I open the
workbook resulting from this code, I have a single column with the
comma-seperated values in it, rather than a matrix of an equal number
of rows and columns.

"I am exporting queries to a 4 sheet XL workbook. The transfer
spreadsheet
method puts a ' in front of all of my numbers, necessitating a
formatting
procedure to remove them and properly format the fields. That's fine
when
there are a manageable number of cells to be formatted, but I have one
sheet
that has a matrix on the order of 175X175 cells that causes my
StripXLFormats
function (shamelessly pilfered from this newsgroup) to take upwards of
15
minutes to complete. This is unacceptable, so I'm trying to work around
the
problem with this one sheet by exporting it first, via TransferText to
a CSV
file, obviating the need to strip the ' from each cell and reformatting
cell
by cell. I then want to open it in Excel and save it as an Excel
workbook.
Then I can export the remaining 3 queries as Excel worksheets and
format them
as needed.

DoCmd.TransferText acExportDelim, , strQuery, strPath & strCSVFile,
True,
""
Set xlObj = CreateObject("excel.application")
With xlObj
Set WkBk = .Workbooks.Open(strPath & strCSVFile)
WkBk.SaveAs Filename:=strPath & strFile
Set WkSht = WkBk.ActiveSheet
WkSht.Name = strSheet
WkBk.Save
DoEvents
WkBk.Close SaveChanges:=True
DoEvents
DoCmd.SetWarnings True
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"qryPEExport", strPath & strFile, True, "PEExport"
StripXLFormats strPath & strFile, "PEExport"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"qryCurveExp", strPath & strFile, True, "Curve"
StripXLFormats strPath & strFile, "Curve"
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9,
"qryPEFactorsExp", strPath & strFile, True, "PE_Factors"
StripXLFormats strPath & strFile, "PE_Factors"
Set WkBk = .Workbooks.Open(strPath & strFile)
Set WkSht = WkBk.Sheets(strSheet)
With WkSht
.Move after:=Worksheets("PE_Factors")
.Range("B2").Select
.Range(Selection, Selection.End(xlDown)).Select
.Range(Selection, Selection.End(xlToRight)).Select
Selection.Style = "Currency"
End With
Screen.MousePointer = 0
.Save
.Quit
End With"


--
ragtopcaddy
------------------------------------------------------------------------
ragtopcaddy's Profile: http://www.excelforum.com/member.php...o&userid=25838
View this thread: http://www.excelforum.com/showthread...hreadid=535577


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Creating an Excel Workbook in Access/VBA - CSV to XLS conversion


The ' happens because the underlying queries have formatted fields. That
forces Excel to force them to text with the '. I'm trying to get around
having to duplicate the queries that are formatted to display data in a
form, with redesigned queries without the formatting to export to Excel.
This would create a maintenance nightmare in my db. I have several forms
whose underlying queries are exported to Excel and I'd like to use them
"as is" for my exports. Otherwise, any change to a form query will
necessitate a change to it's export counterpart.


--
ragtopcaddy
------------------------------------------------------------------------
ragtopcaddy's Profile: http://www.excelforum.com/member.php...o&userid=25838
View this thread: http://www.excelforum.com/showthread...hreadid=535577

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access to Excel check box conversion GD Excel Discussion (Misc queries) 5 April 13th 09 05:49 PM
Creating Excel Worksheets from Access Database jack Excel Discussion (Misc queries) 0 March 14th 07 04:19 PM
Creating a Query in Excel based on an Access Qry... Glenda Excel Discussion (Misc queries) 1 March 23rd 06 07:54 PM
Creating a Product DATABASE in ACCESS or EXCEL and then retrieving Abe Excel Discussion (Misc queries) 1 February 25th 06 03:09 AM
Excel to Access *.MDB conversion [email protected] Excel Discussion (Misc queries) 1 January 27th 06 12:24 PM


All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"