473,396 Members | 1,942 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.

Error during a Kill function in Access VBA

11
Hi all, Thanks in advance,

I have form in an access db (Access 2000) that users can use to (hopefully) import a raw .txt file into access. The user clicks a button and a FileDialog opens to select the .txt file the want to import. When the user selects the file, VBA opens the txt file in Excel (2007) using the following:

objExcel.Workbooks.Open strFilePath

where strFilePath is the file selected in the FileDialog box.

A “With…End With” runs that sets up the .txt file in a format that Access will recognize and at the end of the “With…End With” it saves the txt file as an excel file so that the code can import the new xls file later:

.ActiveWorkbook.SaveAs FileName:="N:\Temp\VR2Temp.xls", FileFormat:=xlExcel8, Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, CreateBackup:=False
End With

The code imports the data from Excel into Access using:

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "Data", "N:\Temp\ VR2Temp.xls", True, "Data!A:E"

Everything works fine up to this point. Here I want to delete the temporary Excel file so that the next time the user runs the code a message box doesn’t popup saying “This file already exists. Replace the existing file?” To delete the file I was going to run the following code:

Dim strDeleteFilePath As String
strDeleteFilePath = "N:\Temp\VR2Temp.xls"
Kill strDeleteFilePath

However, I get the following error:

“Run-time error ‘70’: Permission denied.”

The code works fine if I run it on its own. But when I run it with everything else I get the error. I’m pretty sure that I’m missing a line of code to close something, but I have no idea what that line would be. I tried the following but it didn’t work:

objExcel.Workbooks.Close strFilePath

I’m stumped. Any suggestions?
Jul 16 '07 #1
0 1438

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

Similar topics

1
by: Wayno | last post by:
My php logs are coming up empty. I have done all I can think of, and all that made sense to me. Can someone take a look at my php.ini please and tell me what you think may be the problem. I...
2
by: Randy Harris | last post by:
I thought that I had a grasp of how VBA error handling functioned, but have just become painfully aware that I don't. I thought that the "On Error GoTo 0" in the second sub below would turn off...
6
by: Peter Frost | last post by:
Please help I don't know if this is possible but what I would really like to do is to use On Error Goto to capture the code that is being executed when an error occurs. Any help would be much...
5
by: Ash | last post by:
Hi, I've just installed Visual Studio.NET on my computer, which runs on windows2000 server. When i creat web application and try run it from vb.net, i get the following error: ===============...
7
by: Martin Strojek | last post by:
Hi, I have the following problem with developing some web site. I use Visual Studio 2003 to build a website. I tried Windows 2003 Server and switched now back to Windows XP with PWS but the...
6
by: Ken | last post by:
When running a program in the debugger, what would cause it to crash without any error messages? I get "The program has exited with code 0 (0x0)". The program is a MDI app with threading for...
9
by: dennist685 | last post by:
I created a web project named 'Access' in C:\Inetpub\wwwroot\Access and dropped an .mdb there. I dragged a DetailView to the form, configured it to show two fields of a table, and got...
0
by: HKSHK | last post by:
This list compares the error codes used in VB.NET 2003 with those used in VB6. Error Codes: ============ 3: This Error number is obsolete and no longer used. (Formerly: Return without GoSub)...
3
by: Alexander Eisenhuth | last post by:
Hello, Ctrl+C is not passed to the interpreter (i guess it) while I'm executing a script. Instead i get: forrtl: error (200): program aborting due to control-C event If I start python in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.