Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Delete Shortcut with Code

I am trying to delete all shortcuts that have "log" in them on the desktop
(Win2k). I have unsuccessfully tried the following code:

Kill "C:\Documents and Settings\username\Desktop\*log*.lnk"

I know these shortcuts exist, and my code simply won't delete them. Using
this syntax, even if I put the exact name of the known-to-exist shortcut
(i.e., "Mylog.lnk"), the code does not delete it. Any suggestions, guys?

TIA


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Delete Shortcut with Code

I am not surprised that the *log* didn't work, but the full form worked for
me. I had to change username to my name, and I used PINS2.lnk, and it went
fine.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"zSplash" <zNOSPAMSplash@ gci.net wrote in message
...
I am trying to delete all shortcuts that have "log" in them on the desktop
(Win2k). I have unsuccessfully tried the following code:

Kill "C:\Documents and Settings\username\Desktop\*log*.lnk"

I know these shortcuts exist, and my code simply won't delete them. Using
this syntax, even if I put the exact name of the known-to-exist shortcut
(i.e., "Mylog.lnk"), the code does not delete it. Any suggestions, guys?

TIA




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Delete Shortcut with Code

Thanks, Bob.

So, are you thinking that wildcards won't work? Any other way to "wildcard"
the name (in case it's close, but not exact)?

st.

"Bob Phillips" wrote in message
...
I am not surprised that the *log* didn't work, but the full form worked

for
me. I had to change username to my name, and I used PINS2.lnk, and it went
fine.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"zSplash" <zNOSPAMSplash@ gci.net wrote in message
...
I am trying to delete all shortcuts that have "log" in them on the

desktop
(Win2k). I have unsuccessfully tried the following code:

Kill "C:\Documents and Settings\username\Desktop\*log*.lnk"

I know these shortcuts exist, and my code simply won't delete them.

Using
this syntax, even if I put the exact name of the known-to-exist shortcut
(i.e., "Mylog.lnk"), the code does not delete it. Any suggestions,

guys?

TIA






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Delete Shortcut with Code

Indeed I am.

IU did think of uysing FileSearch which can handle wildcards, but this
seemed to return the shortcut target rather than the shortcut. So I
developed this bit of code to do it

Dim oFSO As Object
Dim oFolder As Object
Dim oSubfolder As Object
Dim oFile As Object

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder("C:\Documents and Settings\Bob\Desktop\")
For Each oFile In oFolder.Files
If oFile.Type = "Shortcut" Then
kill ofile.path
End If
Next
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"zSplash" <zNOSPAMSplash@ gci.net wrote in message
...
Thanks, Bob.

So, are you thinking that wildcards won't work? Any other way to

"wildcard"
the name (in case it's close, but not exact)?

st.

"Bob Phillips" wrote in message
...
I am not surprised that the *log* didn't work, but the full form worked

for
me. I had to change username to my name, and I used PINS2.lnk, and it

went
fine.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"zSplash" <zNOSPAMSplash@ gci.net wrote in message
...
I am trying to delete all shortcuts that have "log" in them on the

desktop
(Win2k). I have unsuccessfully tried the following code:

Kill "C:\Documents and Settings\username\Desktop\*log*.lnk"

I know these shortcuts exist, and my code simply won't delete them.

Using
this syntax, even if I put the exact name of the known-to-exist

shortcut
(i.e., "Mylog.lnk"), the code does not delete it. Any suggestions,

guys?

TIA








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 28
Default Delete Shortcut with Code

Bob! You are wonderful!! I used your code, adding the following to
"wildcard it". It works great. Many, many thanks for your kindness. I'm
smiling again, thanks to you...

... If UCase(InStr(1, oFile.Name, "LOG")) < 0 Then
Kill oFile.Path
End If ...

st.

"Bob Phillips" wrote in message
...
Indeed I am.

IU did think of uysing FileSearch which can handle wildcards, but this
seemed to return the shortcut target rather than the shortcut. So I
developed this bit of code to do it

Dim oFSO As Object
Dim oFolder As Object
Dim oSubfolder As Object
Dim oFile As Object

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder("C:\Documents and Settings\Bob\Desktop\")
For Each oFile In oFolder.Files
If oFile.Type = "Shortcut" Then
kill ofile.path
End If
Next
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"zSplash" <zNOSPAMSplash@ gci.net wrote in message
...
Thanks, Bob.

So, are you thinking that wildcards won't work? Any other way to

"wildcard"
the name (in case it's close, but not exact)?

st.

"Bob Phillips" wrote in message
...
I am not surprised that the *log* didn't work, but the full form

worked
for
me. I had to change username to my name, and I used PINS2.lnk, and it

went
fine.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"zSplash" <zNOSPAMSplash@ gci.net wrote in message
...
I am trying to delete all shortcuts that have "log" in them on the

desktop
(Win2k). I have unsuccessfully tried the following code:

Kill "C:\Documents and Settings\username\Desktop\*log*.lnk"

I know these shortcuts exist, and my code simply won't delete them.

Using
this syntax, even if I put the exact name of the known-to-exist

shortcut
(i.e., "Mylog.lnk"), the code does not delete it. Any suggestions,

guys?

TIA












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Delete Shortcut with Code

Great, and thanks for the feedback.

I forgot about the log bit in the filename in the exchanges, sorry about
that, but you obviously had no problem with it.

Keep smiling!

Bob

"zSplash" <zNOSPAMSplash@ gci.net wrote in message
...
Bob! You are wonderful!! I used your code, adding the following to
"wildcard it". It works great. Many, many thanks for your kindness. I'm
smiling again, thanks to you...

... If UCase(InStr(1, oFile.Name, "LOG")) < 0 Then
Kill oFile.Path
End If ...

st.

"Bob Phillips" wrote in message
...
Indeed I am.

IU did think of uysing FileSearch which can handle wildcards, but this
seemed to return the shortcut target rather than the shortcut. So I
developed this bit of code to do it

Dim oFSO As Object
Dim oFolder As Object
Dim oSubfolder As Object
Dim oFile As Object

Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oFolder = oFSO.GetFolder("C:\Documents and

Settings\Bob\Desktop\")
For Each oFile In oFolder.Files
If oFile.Type = "Shortcut" Then
kill ofile.path
End If
Next
End Sub

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"zSplash" <zNOSPAMSplash@ gci.net wrote in message
...
Thanks, Bob.

So, are you thinking that wildcards won't work? Any other way to

"wildcard"
the name (in case it's close, but not exact)?

st.

"Bob Phillips" wrote in message
...
I am not surprised that the *log* didn't work, but the full form

worked
for
me. I had to change username to my name, and I used PINS2.lnk, and

it
went
fine.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"zSplash" <zNOSPAMSplash@ gci.net wrote in message
...
I am trying to delete all shortcuts that have "log" in them on the
desktop
(Win2k). I have unsuccessfully tried the following code:

Kill "C:\Documents and Settings\username\Desktop\*log*.lnk"

I know these shortcuts exist, and my code simply won't delete

them.
Using
this syntax, even if I put the exact name of the known-to-exist

shortcut
(i.e., "Mylog.lnk"), the code does not delete it. Any

suggestions,
guys?

TIA












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
Shortcut Key to delete rows jcf321 Excel Discussion (Misc queries) 22 September 8th 15 04:36 PM
Keyboard shortcut to delete a row P@ Excel Discussion (Misc queries) 1 June 16th 08 12:39 PM
macro code shortcut Brian Excel Worksheet Functions 4 December 15th 04 08:59 PM
VBA code delete code but ask for password and unlock VBA protection WashoeJeff Excel Programming 0 January 27th 04 07:07 AM
Possible to delete or edit a desktop shortcut? Marchand Durpis Excel Programming 0 July 18th 03 02:20 AM


All times are GMT +1. The time now is 06:53 AM.

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

About Us

"It's about Microsoft Excel"