create a file, put a excel sheet in and a icon

P

pswanie

are there a macro i can put in place to

check if c:\myfolder\inventry.xls exist. if it does run macro called download

if not create c:\myfolder. save as this workbook (the one thats open and
contain this macro) and create a short cut macro on desktop
 
T

Tom Ogilvy

Dim bErr as Boolean
on error resume next
Mkdir "C:\MyFolder"
bErr = (err.Number <> 0)
On Error goto 0
if bErr then
if dir("C:\Myfolder\inventry.xls") <> "" then
Download
else
ThisWorkbook.SaveAs "C:\MyFolder\inventry.xls"
CreateShortCut thisworkbook
end if
Else
ThisWorkbook.SaveAs "C:\MyFolder\inventry.xls"
CreateShortCut thisworkbook
End if


End Sub



Sub CreateShortCut(bk as Workbook)
Dim oWSH As Object
Dim oShortcut As Object
Dim sPathDeskTop As String


Set oWSH = CreateObject("WScript.Shell")
sPathDeskTop = oWSH.SpecialFolders("Desktop")


Set oShortcut = oWSH.CreateShortCut(sPathDeskTop & "\" & _
bk.Name & ".lnk")
With oShortcut
.TargetPath = bk.FullName
.Save
End With
Set oWSH = Nothing


End Sub
 
P

pswanie

thanx man... appreciate!!

take care

Tom Ogilvy said:
Dim bErr as Boolean
on error resume next
Mkdir "C:\MyFolder"
bErr = (err.Number <> 0)
On Error goto 0
if bErr then
if dir("C:\Myfolder\inventry.xls") <> "" then
Download
else
ThisWorkbook.SaveAs "C:\MyFolder\inventry.xls"
CreateShortCut thisworkbook
end if
Else
ThisWorkbook.SaveAs "C:\MyFolder\inventry.xls"
CreateShortCut thisworkbook
End if


End Sub



Sub CreateShortCut(bk as Workbook)
Dim oWSH As Object
Dim oShortcut As Object
Dim sPathDeskTop As String


Set oWSH = CreateObject("WScript.Shell")
sPathDeskTop = oWSH.SpecialFolders("Desktop")


Set oShortcut = oWSH.CreateShortCut(sPathDeskTop & "\" & _
bk.Name & ".lnk")
With oShortcut
.TargetPath = bk.FullName
.Save
End With
Set oWSH = Nothing


End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top