Hi,
Im having trouble deleting a workbook using VBA. What i want is to open a workbook called "xxxxx waiting", make some modification and then save it as readonly but as a "xxxxx complete". I then want to delete the old workvook "xxxxx waiting"
I though i had it cracked but it doesnt seem to work. Ive put the code below if someone could help.
Thanks in advance
Private Sub Save_Click()
ReqNum = Worksheets("chemicals").Range("D2")
With ActiveWorkbook
.SaveAs Filename:="Z:\Req\" & ReqNum & "Complete", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=True, CreateBackup:=False
End With
Kill "Z:\Req\" & ReqNum & "Waiting"
End Sub
Manny
7 1977
I don't think that you can kill yourself. That would be dangerous. :D You'll need another program to open the workbook, save as, close, and kill.
Can you be a bit more specific than "doesn't work"? What does happen?
Hi,
Im having trouble deleting a workbook using VBA. What i want is to open a workbook called "xxxxx waiting", make some modification and then save it as readonly but as a "xxxxx complete". I then want to delete the old workvook "xxxxx waiting"
I though i had it cracked but it doesnt seem to work. Ive put the code below if someone could help.
Thanks in advance
Private Sub Save_Click()
ReqNum = Worksheets("chemicals").Range("D2")
With ActiveWorkbook
.SaveAs Filename:="Z:\Req\" & ReqNum & "Complete", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=True, CreateBackup:=False
End With
Kill "Z:\Req\" & ReqNum & "Waiting"
End Sub
Manny
Hi there -
You might miss the extension of the file
Try this: -
Kill "Z:\Req\" & ReqNum & "Waiting.xls"
-
Have a nice day!
Hi,
Im having trouble deleting a workbook using VBA. What i want is to open a workbook called "xxxxx waiting", make some modification and then save it as readonly but as a "xxxxx complete". I then want to delete the old workvook "xxxxx waiting"
I though i had it cracked but it doesnt seem to work. Ive put the code below if someone could help.
Thanks in advance
Private Sub Save_Click()
ReqNum = Worksheets("chemicals").Range("D2")
With ActiveWorkbook
.SaveAs Filename:="Z:\Req\" & ReqNum & "Complete", _
FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
ReadOnlyRecommended:=True, CreateBackup:=False
End With
Kill "Z:\Req\" & ReqNum & "Waiting"
End Sub
Manny
Hi there -
You might miss the extension of the file and the space between the ReqNum and Waiting:
Try this: -
Kill "Z:\Req\" & ReqNum & " Waiting.xls" ' put a single SPACE before Waiting
-
Have a nice day!
Hi there -
You might miss the extension of the file
Try this: -
Kill "Z:\Req\" & ReqNum & "Waiting.xls"
-
Have a nice day!
Thanks worked a treat!!!!
... You might miss the extension of the file and the space between the ReqNum and Waiting ...
Thanks again, fplesco.
I'm curious though - are you sure about the space? I've always used Format$() function when printing or concatenating numbers, specifically to prevent the insertion of the extra space. Can never remember though, whether it's before or after the number. (I guess I should go and check.)
... I've always used Format$() function when printing or concatenating numbers, specifically to prevent the insertion of the extra space. Can never remember though, whether it's before or after the number. (I guess I should go and check.)
Well, I just set up this elaborate testing scenario...
which produced the output " 5 h 6 f 7 and confirmed that printing, at least, leaves a space before the number.
But of course (and I'm sure you know where this is heading) a quick test with this code... - Dim A As String
-
A = 5 & "h" & 6 & "f" & 7
-
Debug.Print A
...produced " 5h6f7", thus refuting my "extra space" theory. Obviously I've been using Format unnecessarily. Slightly annoying, but I guess it's good that I know better now.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: A frustrated developer |
last post by:
The following article discussed how to use the Excel, close and kill it:
http://support.microsoft.com/default.aspx?scid=kb;en-us;317109
But if you added a oBook.SaveAs(...) to save the workbook...
|
by: Josema |
last post by:
Hi to all,
I have a windows application that uses workbooks, sheets, ranges, etc...
This application is consumed by few clients.
Some weeks ago I had problems to kill excel.exe process but i...
|
by: hari krishna |
last post by:
hi,
I am generating excel reports through vb.Net. After creating
excel.application and the report is generated, each report leaves Excel in
memory. I can see them in task manager in Process tab...
|
by: charmis |
last post by:
Hi everyone,
I am trying to include one feature using excel object in my application.
I am giving the code to create and kill the process , that i got from
Microsoft site.......but nothing is...
|
by: Lee Gillie |
last post by:
I need to be able to kill a process programmatically under ASP.NET. IIS
runs under the local system account. The user accessing the web is using
anonymous access.
We would prefer NOT to grant...
|
by: touf |
last post by:
Hi,
I use the folowing code to create a new Excel file using a query
It creates an excel file and save it on the disc, but When I double-clic on
it (explorer) it open Excel and bloc,(don't display...
|
by: ChrisFrohlich |
last post by:
I have been trying to use the Office PIA's to write an ASP.NEt page to:
1. Open a template workbook
2. Populate some data
3. Save the file back to the server
4. Quit Excel and free up Memory
I...
|
by: bettatronic |
last post by:
The goal : to have class which is able to add some OLE objects on the sheet runtime. Instances of the class must be accessible from any public/private module.
Okay, I've experimented for so long &...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
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...
| |