473,396 Members | 1,760 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,396 software developers and data experts.

WkBk.Close SaveChanges:=True causes computer to hang - CSV to XLS conversion

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.

The problem arises in the following code on the line "WkBk.Close SaveChanges:
=True". I think it's because it's a CSV file that I'm trying to save as an
Excel workbook. Any suggestions would be deeply appreciated.

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

--
Bill Reed

"If you can't laugh at yourself, laugh at somebody else"

Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200604/1
Apr 21 '06 #1
0 2611

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Daniel | last post by:
TcpClient close() method socket leak when i use TcpClient to open a connection, send data and close the TcpClient with myTcpClientInstance.Close(); it takes 60 seconds for the actual socket on...
1
by: Andrei Ryazanov | last post by:
Hello, All! i try the following text from mvps.org Sub sTestXL() Dim objXL As Object Dim strWhat As String, boolXL As Boolean Dim objActiveWkb As Object If fIsAppRunning("Excel") Then Set...
7
by: Shivalee Gupta via AccessMonster.com | last post by:
i am working on access 2000. can i write a code which will tell me, at the time of closing the database, that at what time i had opened the database and at what time i am closing it? i am in a...
3
by: David Berman | last post by:
Hi, I've written an application to do a while bunch of Excel automation. I open a file, scan through all the worksheets, extract data, and then I try to close Excel. However, I can see that I'm...
0
by: Bruce | last post by:
I have an MDI parent form frmMain that *should* allow multiple instances of a child form frmChild. The frmChild operates completely independently of frmMain (aside from being an MDI child), and...
5
by: John Tenney | last post by:
If I have a windows form (System.Windows.Forms.Form) open and I push the pin on the toolbox to keep the docked window open, Visual Studios 2003 pegs the processor and basically hangs my computer. I...
4
by: mammen | last post by:
Hello, I'm writing trace log of various actions happening in my ASP.NET web application by opening a text file when the user logs in to the system and closing the file while the user logs out....
1
by: Flemming | last post by:
Hi I have created a word add-in and after having selected some documents into a listview the documents is opened and manipulated... with this code... wdApp = CType(GetObject("",...
1
by: sarabhjeet | last post by:
Hello all, Actually i need to close a dialog automatically after 5-6 seconds. For it what should i do,please help me.I am using wxTimer self.MB =...
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.