Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Re: system32\tskill.exe And EXCEL by VBS file...

Reply
 
Old 01-11-2009   #1 (permalink)
Pegasus \(MVP\)


 
 

Re: system32\tskill.exe And EXCEL by VBS file...


"Benny Pedersen" <b.pedersen@xxxxxx> wrote in message
news:7f5f9463-c0a8-4600-a2fe-1c56e117bd1f@xxxxxx
Quote:

>
> Hi.
>
> I got a job about writing some txt files into a Excel sheet.
>
> Some text1: value1
> Some text2: value2
> ... and so on...
>
> So today I wrote a vbs file, drag and drop the txt file...
> The "C:\Target\" folder is created on first run.
>
> The first row with the description (Some text1) is written
> on first run. Any other run write the second col (value1)
> into the next column.
>
> The next run drag and drop, would write the other values
> into the first free colomn, and so on...
>
> A problem I found was that if one said something wrong to the
> msgBoxes from Excel, or whatever, then it could freeze the sheet...
> To avoid that, I simply used the "tskill.exe" as shown.
> In other words: Say No to the first question, and the freeze
> problem is gone
>
> My knowlede about Excel syntax is almost one line, something
> like this: oExcelSheet.cells(1,1).value
> so any sugestions would be good
>
> Benny Pedersen,
> www.fineraw.com
> PS. Safe to run, just try:
Since you don't appear to have any specific questions, here are a couple of
general comments. To kill an application such as Excel with taskkill.exe is
equivalent to fixing a car with a sledge hammer. Not recommended, not good
practice. Much better to do things in an orderly fashion: Close your
spreadsheets, either by saving them or with the "NoSave" option, then set
your Excel object to "nothing".

My personal preference (which many people do not share) is to maintain a
strong structure in my programs, e.g. like so:

GetParms
OpenFiles
ConstructArray
PlugInValues
SaveFiles

'-----------------
'Task description
'-----------------
sub GetParms
[code]
end sub
'-----------------
'Task description
'-----------------
sub OpenFiles
[code]
end sub
'-----------------
'Task description
'-----------------
sub ConstructArray
[code]
end sub

The main part of the program is a high-level statement of each task. It
clearly shows the reader the major tasks to be performed. It contains no
code other than invoking various subroutines. Each subroutine performs a
specific, well-defined task such as your KillApp subroutine, preferably
containing no more lines than will fit onto a single screen. It also uses
local variables whenever possible.

You tend to mix the main routine and the subroutines freely, which is
functionally equivalent but which destroys the structure and does not
encourage modular programming. Your main routine goes over dozens of lines
with no visible structure, which often ends up in spaghetti code. When
inspecting a single line of code in such a program you usually have to
untangle the whole program before you can work where it stands in the scheme
of things and what it does. Look at some program that you wrote a year ago
to see what I mean!

Just my two bobs worth.



My System SpecsSystem Spec
Old 01-11-2009   #2 (permalink)
Richard Mueller [MVP]


 
 

Re: system32\tskill.exe And EXCEL by VBS file...


"Pegasus (MVP)" <I.can@xxxxxx> wrote in message
news:OrIsmIBdJHA.1132@xxxxxx
Quote:

>
> "Benny Pedersen" <b.pedersen@xxxxxx> wrote in message
> news:7f5f9463-c0a8-4600-a2fe-1c56e117bd1f@xxxxxx
Quote:

>>
>> Hi.
>>
>> I got a job about writing some txt files into a Excel sheet.
>>
>> Some text1: value1
>> Some text2: value2
>> ... and so on...
>>
>> So today I wrote a vbs file, drag and drop the txt file...
>> The "C:\Target\" folder is created on first run.
>>
>> The first row with the description (Some text1) is written
>> on first run. Any other run write the second col (value1)
>> into the next column.
>>
>> The next run drag and drop, would write the other values
>> into the first free colomn, and so on...
>>
>> A problem I found was that if one said something wrong to the
>> msgBoxes from Excel, or whatever, then it could freeze the sheet...
>> To avoid that, I simply used the "tskill.exe" as shown.
>> In other words: Say No to the first question, and the freeze
>> problem is gone
>>
>> My knowlede about Excel syntax is almost one line, something
>> like this: oExcelSheet.cells(1,1).value
>> so any sugestions would be good
>>
>> Benny Pedersen,
>> www.fineraw.com
>> PS. Safe to run, just try:
>
> Since you don't appear to have any specific questions, here are a couple
> of general comments. To kill an application such as Excel with
> taskkill.exe is equivalent to fixing a car with a sledge hammer. Not
> recommended, not good practice. Much better to do things in an orderly
> fashion: Close your spreadsheets, either by saving them or with the
> "NoSave" option, then set your Excel object to "nothing".
>
> My personal preference (which many people do not share) is to maintain a
> strong structure in my programs, e.g. like so:
>
> GetParms
> OpenFiles
> ConstructArray
> PlugInValues
> SaveFiles
>
> '-----------------
> 'Task description
> '-----------------
> sub GetParms
> [code]
> end sub
> '-----------------
> 'Task description
> '-----------------
> sub OpenFiles
> [code]
> end sub
> '-----------------
> 'Task description
> '-----------------
> sub ConstructArray
> [code]
> end sub
>
> The main part of the program is a high-level statement of each task. It
> clearly shows the reader the major tasks to be performed. It contains no
> code other than invoking various subroutines. Each subroutine performs a
> specific, well-defined task such as your KillApp subroutine, preferably
> containing no more lines than will fit onto a single screen. It also uses
> local variables whenever possible.
>
> You tend to mix the main routine and the subroutines freely, which is
> functionally equivalent but which destroys the structure and does not
> encourage modular programming. Your main routine goes over dozens of lines
> with no visible structure, which often ends up in spaghetti code. When
> inspecting a single line of code in such a program you usually have to
> untangle the whole program before you can work where it stands in the
> scheme of things and what it does. Look at some program that you wrote a
> year ago to see what I mean!
>
> Just my two bobs worth.
>
Besides closing the worksheet you should quit the application, but I see
statements that do that in your code. I try to anticipate all possible
errors and trap them so I can close and quit. Otherwise the spreadsheet is
help open. For every statement that can raise an error (after testing the
script), I have "On Error Resume Next" before, then after the statement I
use "If (Err.Number <> 0) Then" to trap the error and handle it (including
closing the worksheet and quitting the app), then I restore normal error
handling with "On Error GoTo 0". If an unanticipated error is raised, I use
Task Manager to kill the app. I always restore normal error handling so if
something unanticated happens I know it. There really is no better solution
in VBScript.

--
Richard Mueller
MVP Directory Services
Hilltop Lab - http://www.rlmueller.net
--


My System SpecsSystem Spec
Old 01-11-2009   #3 (permalink)
Benny Pedersen


 
 

Re: system32\tskill.exe And EXCEL by VBS file...

On Jan 11, 6:29*pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
Quote:

> "Benny Pedersen" <b.peder...@xxxxxx> wrote in message
>
> news:7f5f9463-c0a8-4600-a2fe-1c56e117bd1f@xxxxxx
>
>
>
>
>
>
>
Quote:

> > Hi.
>
Quote:

> > I got a job about writing some txt files into a Excel sheet.
>
Quote:

> > Some text1: value1
> > Some text2: value2
> > ... and so on...
>
Quote:

> > So today I wrote a vbs file, drag and drop the txt file...
> > The "C:\Target\" folder is created on first run.
>
Quote:

> > The first row with the description (Some text1) is written
> > on first run. Any other run write the second col (value1)
> > into the next column.
>
Quote:

> > The next run drag and drop, would write the other values
> > into the first free colomn, and so on...
>
Quote:

> > A problem I found was that if one said something wrong to the
> > msgBoxes from Excel, or whatever, then it could freeze the sheet...
> > To avoid that, I simply used the "tskill.exe" as shown.
> > In other words: Say No to the first question, and the freeze
> > problem is gone
>
Quote:

> > My knowlede about Excel syntax is almost one line, something
> > like this: oExcelSheet.cells(1,1).value
> > so any sugestions would be good
>
Quote:

> > Benny Pedersen,
> >www.fineraw.com
> > PS. Safe to run, just try:
>
> Since you don't appear to have any specific questions, here are a couple of
> general comments. To kill an application such as Excel with taskkill.exe is
> equivalent to fixing a car with a sledge hammer. Not recommended, not good
> practice. Much better to do things in an orderly fashion: Close your
> spreadsheets, either by saving them or with the "NoSave" option, then set
> your Excel object to "nothing".
>
> My personal preference (which many people do not share) is to maintain a
> strong structure in my programs, e.g. like so:
>
> GetParms
> OpenFiles
> ConstructArray
> PlugInValues
> SaveFiles
>
> '-----------------
> 'Task description
> '-----------------
> sub GetParms
> [code]
> end sub
> '-----------------
> 'Task description
> '-----------------
> sub OpenFiles
> [code]
> end sub
> '-----------------
> 'Task description
> '-----------------
> sub ConstructArray
> [code]
> end sub
>
> The main part of the program is a high-level statement of each task. It
> clearly shows the reader the major tasks to be performed. It contains no
> code other than invoking various subroutines. Each subroutine performs a
> specific, well-defined task such as your KillApp subroutine, preferably
> containing no more lines than will fit onto a single screen. It also uses
> local variables whenever possible.
>
> You tend to mix the main routine and the subroutines freely, which is
> functionally equivalent but which destroys the structure and does not
> encourage modular programming. Your main routine goes over dozens of lines
> with no visible structure, which often ends up in spaghetti code. When
> inspecting a single line of code in such a program you usually have to
> untangle the whole program before you can work where it stands in the scheme
> of things and what it does. Look at some program that you wrote a year ago
> to see what I mean!
>
> Just my two bobs worth.- Hide quoted text -
>
> - Show quoted text -
Thanks Richard and Pegasys for your replys

Because I don't know much Excel syntax, the sledge hammer.(kill excel)
metode was the only solution I could figure out.
The problem came after this:

oExcelApp.activeWorkBook.saveAs sTargetFile
oExcelApp.activeWorkBook.close
oExcelApp.application.quit

After the first line of the above 3 lines, then Excel show a msgbox
with 3 options and one question: "C:\Target already exist. Should it
be overwritten?"
The 3 options is this: YES, NO, Cancel.
If the user press another button than YES, then Excel could freeze (is
open but not visible and not saved).
So instead of CTRL+ALT+Delete and kill, I just constructed a sledge
hammer instead...

Benny

My System SpecsSystem Spec
Old 01-11-2009   #4 (permalink)
Benny Pedersen


 
 

Re: system32\tskill.exe And EXCEL by VBS file...

On Jan 11, 7:02*pm, "Richard Mueller [MVP]" <rlmueller-
nos...@xxxxxx> wrote:
Quote:

> "Pegasus (MVP)" <I....@xxxxxx> wrote in message
>
> news:OrIsmIBdJHA.1132@xxxxxx
>
>
>
>
>
>
>
Quote:

> > "Benny Pedersen" <b.peder...@xxxxxx> wrote in message
> >news:7f5f9463-c0a8-4600-a2fe-1c56e117bd1f@xxxxxx
>
Quote:
Quote:

> >> Hi.
>
Quote:
Quote:

> >> I got a job about writing some txt files into a Excel sheet.
>
Quote:
Quote:

> >> Some text1: value1
> >> Some text2: value2
> >> ... and so on...
>
Quote:
Quote:

> >> So today I wrote a vbs file, drag and drop the txt file...
> >> The "C:\Target\" folder is created on first run.
>
Quote:
Quote:

> >> The first row with the description (Some text1) is written
> >> on first run. Any other run write the second col (value1)
> >> into the next column.
>
Quote:
Quote:

> >> The next run drag and drop, would write the other values
> >> into the first free colomn, and so on...
>
Quote:
Quote:

> >> A problem I found was that if one said something wrong to the
> >> msgBoxes from Excel, or whatever, then it could freeze the sheet...
> >> To avoid that, I simply used the "tskill.exe" as shown.
> >> In other words: Say No to the first question, and the freeze
> >> problem is gone
>
Quote:
Quote:

> >> My knowlede about Excel syntax is almost one line, something
> >> like this: oExcelSheet.cells(1,1).value
> >> so any sugestions would be good
>
Quote:
Quote:

> >> Benny Pedersen,
> >>www.fineraw.com
> >> PS. Safe to run, just try:
>
Quote:

> > Since you don't appear to have any specific questions, here are a couple
> > of general comments. To kill an application such as Excel with
> > taskkill.exe is equivalent to fixing a car with a sledge hammer. Not
> > recommended, not good practice. Much better to do things in an orderly
> > fashion: Close your spreadsheets, either by saving them or with the
> > "NoSave" option, then set your Excel object to "nothing".
>
Quote:

> > My personal preference (which many people do not share) is to maintain a
> > strong structure in my programs, e.g. like so:
>
Quote:

> > GetParms
> > OpenFiles
> > ConstructArray
> > PlugInValues
> > SaveFiles
>
Quote:

> > '-----------------
> > 'Task description
> > '-----------------
> > sub GetParms
> > [code]
> > end sub
> > '-----------------
> > 'Task description
> > '-----------------
> > sub OpenFiles
> > [code]
> > end sub
> > '-----------------
> > 'Task description
> > '-----------------
> > sub ConstructArray
> > [code]
> > end sub
>
Quote:

> > The main part of the program is a high-level statement of each task. It
> > clearly shows the reader the major tasks to be performed. It contains no
> > code other than invoking various subroutines. Each subroutine performs a
> > specific, well-defined task such as your KillApp subroutine, preferably
> > containing no more lines than will fit onto a single screen. It also uses
> > local variables whenever possible.
>
Quote:

> > You tend to mix the main routine and the subroutines freely, which is
> > functionally equivalent but which destroys the structure and does not
> > encourage modular programming. Your main routine goes over dozens of lines
> > with no visible structure, which often ends up in spaghetti code. When
> > inspecting a single line of code in such a program you usually have to
> > untangle the whole program before you can work where it stands in the
> > scheme of things and what it does. Look at some program that you wrote a
> > year ago to see what I mean!
>
Quote:

> > Just my two bobs worth.
>
> Besides closing the worksheet you should quit the application, but I see
> statements that do that in your code. I try to anticipate all possible
> errors and trap them so I can close and quit. Otherwise the spreadsheet is
> help open. For every statement that can raise an error (after testing the
> script), I have "On Error Resume Next" before, then after the statement I
> use "If (Err.Number <> 0) Then" to trap the error and handle it (including
> closing the worksheet and quitting the app), then I restore normal error
> handling with "On Error GoTo 0". If an unanticipated error is raised, I use
> Task Manager to kill the app. I always restore normal error handling so if
> something unanticated happens I know it. There really is no better solution
> in VBScript.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab -http://www.rlmueller.net
> --- Hide quoted text -
>
> - Show quoted text -
Thanks

It should be saved after the array was written into the sheet, (of
cause).

Hmm, I would prefer the sheet was left open, so the user self could
save and close the Excel app instead of this:

oExcelApp.activeWorkBook.saveAs sTargetFile
oExcelApp.activeWorkBook.close
oExcelApp.application.quit


My System SpecsSystem Spec
Old 01-11-2009   #5 (permalink)
Pegasus \(MVP\)


 
 

Re: system32\tskill.exe And EXCEL by VBS file...


"Benny Pedersen" <b.pedersen@xxxxxx> wrote in message
news:2b0d0961-ed36-4f8b-8299-
Thanks Richard and Pegasys for your replys

Because I don't know much Excel syntax, the sledge hammer.(kill excel)
metode was the only solution I could figure out.
The problem came after this:

oExcelApp.activeWorkBook.saveAs sTargetFile
oExcelApp.activeWorkBook.close
oExcelApp.application.quit

After the first line of the above 3 lines, then Excel show a msgbox
with 3 options and one question: "C:\Target already exist. Should it
be overwritten?"
The 3 options is this: YES, NO, Cancel.
If the user press another button than YES, then Excel could freeze (is
open but not visible and not saved).
So instead of CTRL+ALT+Delete and kill, I just constructed a sledge
hammer instead...

Benny

============

Why not let VB Script handle this issue?

if oFSO.FileExists(sTargetFile) then
msgbox " . . . "
[Take appropriate action, e.g. delete the file]
etc.
end if

In this way you stay in control at all times!


My System SpecsSystem Spec
Old 01-11-2009   #6 (permalink)
Benny Pedersen


 
 

Re: system32\tskill.exe And EXCEL by VBS file...

On Jan 11, 7:02*pm, "Richard Mueller [MVP]" <rlmueller-
nos...@xxxxxx> wrote:
Quote:

> "Pegasus (MVP)" <I....@xxxxxx> wrote in message
>
> news:OrIsmIBdJHA.1132@xxxxxx
>
>
>
>
>
>
>
Quote:

> > "Benny Pedersen" <b.peder...@xxxxxx> wrote in message
> >news:7f5f9463-c0a8-4600-a2fe-1c56e117bd1f@xxxxxx
>
Quote:
Quote:

> >> Hi.
>
Quote:
Quote:

> >> I got a job about writing some txt files into a Excel sheet.
>
Quote:
Quote:

> >> Some text1: value1
> >> Some text2: value2
> >> ... and so on...
>
Quote:
Quote:

> >> So today I wrote a vbs file, drag and drop the txt file...
> >> The "C:\Target\" folder is created on first run.
>
Quote:
Quote:

> >> The first row with the description (Some text1) is written
> >> on first run. Any other run write the second col (value1)
> >> into the next column.
>
Quote:
Quote:

> >> The next run drag and drop, would write the other values
> >> into the first free colomn, and so on...
>
Quote:
Quote:

> >> A problem I found was that if one said something wrong to the
> >> msgBoxes from Excel, or whatever, then it could freeze the sheet...
> >> To avoid that, I simply used the "tskill.exe" as shown.
> >> In other words: Say No to the first question, and the freeze
> >> problem is gone
>
Quote:
Quote:

> >> My knowlede about Excel syntax is almost one line, something
> >> like this: oExcelSheet.cells(1,1).value
> >> so any sugestions would be good
>
Quote:
Quote:

> >> Benny Pedersen,
> >>www.fineraw.com
> >> PS. Safe to run, just try:
>
Quote:

> > Since you don't appear to have any specific questions, here are a couple
> > of general comments. To kill an application such as Excel with
> > taskkill.exe is equivalent to fixing a car with a sledge hammer. Not
> > recommended, not good practice. Much better to do things in an orderly
> > fashion: Close your spreadsheets, either by saving them or with the
> > "NoSave" option, then set your Excel object to "nothing".
>
Quote:

> > My personal preference (which many people do not share) is to maintain a
> > strong structure in my programs, e.g. like so:
>
Quote:

> > GetParms
> > OpenFiles
> > ConstructArray
> > PlugInValues
> > SaveFiles
>
Quote:

> > '-----------------
> > 'Task description
> > '-----------------
> > sub GetParms
> > [code]
> > end sub
> > '-----------------
> > 'Task description
> > '-----------------
> > sub OpenFiles
> > [code]
> > end sub
> > '-----------------
> > 'Task description
> > '-----------------
> > sub ConstructArray
> > [code]
> > end sub
>
Quote:

> > The main part of the program is a high-level statement of each task. It
> > clearly shows the reader the major tasks to be performed. It contains no
> > code other than invoking various subroutines. Each subroutine performs a
> > specific, well-defined task such as your KillApp subroutine, preferably
> > containing no more lines than will fit onto a single screen. It also uses
> > local variables whenever possible.
>
Quote:

> > You tend to mix the main routine and the subroutines freely, which is
> > functionally equivalent but which destroys the structure and does not
> > encourage modular programming. Your main routine goes over dozens of lines
> > with no visible structure, which often ends up in spaghetti code. When
> > inspecting a single line of code in such a program you usually have to
> > untangle the whole program before you can work where it stands in the
> > scheme of things and what it does. Look at some program that you wrote a
> > year ago to see what I mean!
>
Quote:

> > Just my two bobs worth.
>
> Besides closing the worksheet you should quit the application, but I see
> statements that do that in your code. I try to anticipate all possible
> errors and trap them so I can close and quit. Otherwise the spreadsheet is
> help open. For every statement that can raise an error (after testing the
> script), I have "On Error Resume Next" before, then after the statement I
> use "If (Err.Number <> 0) Then" to trap the error and handle it (including
> closing the worksheet and quitting the app), then I restore normal error
> handling with "On Error GoTo 0". If an unanticipated error is raised, I use
> Task Manager to kill the app. I always restore normal error handling so if
> something unanticated happens I know it. There really is no better solution
> in VBScript.
>
> --
> Richard Mueller
> MVP Directory Services
> Hilltop Lab -http://www.rlmueller.net
> --- Hide quoted text -
>
> - Show quoted text -
Thanks

It should be saved after the array was written into the sheet, (of
cause).

I would prefer the sheet was saved without the annoying msgbox by
Excel with 3 options
oExcelApp.activeWorkBook.saveAs sTargetFile

But if I can't avoid it, it maybe better the sheet is left open and
visible, so the user self should save and close the Excel app
instead.

oExcelApp.activeWorkBook.saveAs sTargetFile
oExcelApp.activeWorkBook.close
oExcelApp.application.quit

Benny
My System SpecsSystem Spec
Old 01-11-2009   #7 (permalink)
Benny Pedersen


 
 

Re: system32\tskill.exe And EXCEL by VBS file...

On Jan 11, 11:13*pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
Quote:

> "Benny Pedersen" <b.peder...@xxxxxx> wrote in message
>
> news:2b0d0961-ed36-4f8b-8299-
> Thanks Richard and Pegasys for your replys
>
> Because I don't know much Excel syntax, the sledge hammer.(kill excel)
> metode was the only solution I could figure out.
> The problem came after this:
>
> oExcelApp.activeWorkBook.saveAs sTargetFile
> oExcelApp.activeWorkBook.close
> oExcelApp.application.quit
>
> After the first line of the above 3 lines, then Excel show a msgbox
> with 3 options and one question: "C:\Target already exist. Should it
> be overwritten?"
> The 3 options is this: YES, NO, Cancel.
> If the user press another button than YES, then Excel could freeze (is
> open but not visible and not saved).
> So instead of CTRL+ALT+Delete and kill, I just constructed a sledge
> hammer instead...
>
> Benny
>
> ============
>
> Why not let VB Script handle this issue?
>
> if oFSO.FileExists(sTargetFile) then
> * msgbox " . . . "
> * [Take appropriate action, e.g. delete the file]
> * etc.
> end if
>
> In this way you stay in control at all times!
Yes, that is a good idea. Since I already made a backup of the xls
file (see the subrutine named BAK), then I could just fso.delete it
and then save it

Benny
My System SpecsSystem Spec
Old 01-11-2009   #8 (permalink)
Pegasus \(MVP\)


 
 

Re: system32\tskill.exe And EXCEL by VBS file...


"Benny Pedersen" <b.pedersen@xxxxxx> wrote in message
news:b64bfccd-2a5f-46f5-bed3-6e091142707d@xxxxxx
On Jan 11, 11:13 pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
Quote:

> "Benny Pedersen" <b.peder...@xxxxxx> wrote in message
>
> news:2b0d0961-ed36-4f8b-8299-
> Thanks Richard and Pegasys for your replys
>
> Because I don't know much Excel syntax, the sledge hammer.(kill excel)
> metode was the only solution I could figure out.
> The problem came after this:
>
> oExcelApp.activeWorkBook.saveAs sTargetFile
> oExcelApp.activeWorkBook.close
> oExcelApp.application.quit
>
> After the first line of the above 3 lines, then Excel show a msgbox
> with 3 options and one question: "C:\Target already exist. Should it
> be overwritten?"
> The 3 options is this: YES, NO, Cancel.
> If the user press another button than YES, then Excel could freeze (is
> open but not visible and not saved).
> So instead of CTRL+ALT+Delete and kill, I just constructed a sledge
> hammer instead...
>
> Benny
>
> ============
>
> Why not let VB Script handle this issue?
>
> if oFSO.FileExists(sTargetFile) then
> msgbox " . . . "
> [Take appropriate action, e.g. delete the file]
> etc.
> end if
>
> In this way you stay in control at all times!
Yes, that is a good idea. Since I already made a backup of the xls
file (see the subrutine named BAK), then I could just fso.delete it
and then save it

Benny

====================

Great! You're now fixing the car with a spanner (the tool intended for car
repairs) instead of the sledge hammer.


My System SpecsSystem Spec
Old 01-11-2009   #9 (permalink)
Benny Pedersen


 
 

Re: system32\tskill.exe And EXCEL by VBS file...

On Jan 11, 11:28*pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
Quote:

> "Benny Pedersen" <b.peder...@xxxxxx> wrote in message
>
> news:b64bfccd-2a5f-46f5-bed3-6e091142707d@xxxxxx
> On Jan 11, 11:13 pm, "Pegasus \(MVP\)" <I....@xxxxxx> wrote:
>
>
>
>
>
Quote:

> > "Benny Pedersen" <b.peder...@xxxxxx> wrote in message
>
Quote:

> > news:2b0d0961-ed36-4f8b-8299-
> > Thanks Richard and Pegasys for your replys
>
Quote:

> > Because I don't know much Excel syntax, the sledge hammer.(kill excel)
> > metode was the only solution I could figure out.
> > The problem came after this:
>
Quote:

> > oExcelApp.activeWorkBook.saveAs sTargetFile
> > oExcelApp.activeWorkBook.close
> > oExcelApp.application.quit
>
Quote:

> > After the first line of the above 3 lines, then Excel show a msgbox
> > with 3 options and one question: "C:\Target already exist. Should it
> > be overwritten?"
> > The 3 options is this: YES, NO, Cancel.
> > If the user press another button than YES, then Excel could freeze (is
> > open but not visible and not saved).
> > So instead of CTRL+ALT+Delete and kill, I just constructed a sledge
> > hammer instead...
>
Quote:

> > Benny
>
Quote:

> > ============
>
Quote:

> > Why not let VB Script handle this issue?
>
Quote:

> > if oFSO.FileExists(sTargetFile) then
> > msgbox " . . . "
> > [Take appropriate action, e.g. delete the file]
> > etc.
> > end if
>
Quote:

> > In this way you stay in control at all times!
>
> Yes, that is a good idea. Since I already made a backup of the xls
> file (see the subrutine named BAK), then I could just fso.delete it
> and then save it
>
> Benny
>
> ====================
>
> Great! You're now fixing the car with a spanner (the tool intended for car
> repairs) instead of the sledge hammer.- Hide quoted text -
>
> - Show quoted text -
Yes I thought, but not solved anyway.

When I said "fso.deleteFile(sTargetFile)", Excel said Permision
denied.

So the xml file should not be created before Excel is open. Instead
just write the sheet, then save it. But that would not work neither.
The file should be opened for appending.

I tried to predict some of the problems. So when she later call my
phone about the hang problem, then I could just say use the sledge
hammer...
The poll results will be recived later and I don't know the number of
answers. So maybe there come several columns...

So the hang problem is still unsolved...

Benny
My System SpecsSystem Spec
Old 01-11-2009   #10 (permalink)
Pegasus \(MVP\)


 
 

Re: system32\tskill.exe And EXCEL by VBS file...


"Benny Pedersen" <b.pedersen@xxxxxx> wrote in message
news:2e1e4cb8-e18f-4429-a174-
Yes I thought, but not solved anyway.

When I said "fso.deleteFile(sTargetFile)", Excel said Permision
denied.

So the xml file should not be created before Excel is open. Instead
just write the sheet, then save it. But that would not work neither.
The file should be opened for appending.

I tried to predict some of the problems. So when she later call my
phone about the hang problem, then I could just say use the sledge
hammer...
The poll results will be recived later and I don't know the number of
answers. So maybe there come several columns...

So the hang problem is still unsolved...

Benny

======================

You need to do a little homework:
- Why is permission denied?
- Is it an NTFS permissions issue?
- Is the file kept open by Excel? If so, why don't you close it first?
- Is the file kept open by another user?
- If you pause the script at the critical spot, can you delete the file with
Explorer?


My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
File in Windows\System32 Vista file management
How To Get Excel File Folder to Associate with Excel File Open Vista file management
Vista ASP.NET 2.0 Cannot open Excel File using Microsoft.Excel 12.0 COM object Microsoft Office
why the file in system32 will be delete Vista General
change file name in system32 Vista security


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46