create a file, put a excel sheet in and a icon
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 |
create a file, put a excel sheet in and a icon
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 -- Regards, Tom Ogilvy "pswanie" wrote: 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 |
create a file, put a excel sheet in and a icon
thanx man... appreciate!!
take care "Tom Ogilvy" wrote: 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 -- Regards, Tom Ogilvy "pswanie" wrote: 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 |
All times are GMT +1. The time now is 06:35 PM. |
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com