Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quick fix
Hi, Where have I gone wrong? ActiveSheet.Protect "sports" Application.GetSaveAsFilename ( _ InitialFileName:= "C:\R2\Sports Return\" & Format(Now(), "dd_mm_yy") & "_sportsreturn" FileFilter = "Microsoft Excel Workbook (*.xls), *.xls") End Sub I know im nearly there but I cant get the end of the macro right!!!1 Please help -- Cobbcouk ------------------------------------------------------------------------ Cobbcouk's Profile: http://www.excelforum.com/member.php...o&userid=32143 View this thread: http://www.excelforum.com/showthread...hreadid=531827 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quick fix
Cobbcouk,
You need to grab the return value, otherwise it's a useless call. Dim FileName as Variant FileName = Application.GetSaveAsFilename ( .... 'Check the user did not cancel If FileName < False then ...... NickHK "Cobbcouk" wrote in message ... Hi, Where have I gone wrong? ActiveSheet.Protect "sports" Application.GetSaveAsFilename ( _ InitialFileName:= "C:\R2\Sports Return\" & Format(Now(), "dd_mm_yy") & "_sportsreturn" FileFilter = "Microsoft Excel Workbook (*.xls), *.xls") End Sub I know im nearly there but I cant get the end of the macro right!!!1 Please help -- Cobbcouk ------------------------------------------------------------------------ Cobbcouk's Profile: http://www.excelforum.com/member.php...o&userid=32143 View this thread: http://www.excelforum.com/showthread...hreadid=531827 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quick fix
Sub test()
Dim fileName As String ActiveSheet.Protect "sports" fileName = Application.GetSaveAsFilename( _ InitialFileName:="U:\" & Format(Date, "dd_mm_yy") & "_sportsreturn", _ FileFilter:="Microsoft Excel Workbook (*.xls), *.xls" _ ) ActiveWorkbook.SaveAs fileName:=fileName End Sub HTH -- AP "Cobbcouk" a écrit dans le message de ... Hi, Where have I gone wrong? ActiveSheet.Protect "sports" Application.GetSaveAsFilename ( _ InitialFileName:= "C:\R2\Sports Return\" & Format(Now(), "dd_mm_yy") & "_sportsreturn" FileFilter = "Microsoft Excel Workbook (*.xls), *.xls") End Sub I know im nearly there but I cant get the end of the macro right!!!1 Please help -- Cobbcouk ------------------------------------------------------------------------ Cobbcouk's Profile: http://www.excelforum.com/member.php...o&userid=32143 View this thread: http://www.excelforum.com/showthread...hreadid=531827 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quick fix
Thanks for the quick response but im learning as i go with VBA. What d you mean? And where should I write the filename? I kind of understan the App.Get save as format but like I say, Im learnin -- Cobbcou ----------------------------------------------------------------------- Cobbcouk's Profile: http://www.excelforum.com/member.php...fo&userid=3214 View this thread: http://www.excelforum.com/showthread.php?threadid=53182 |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quick fix
Cobbcouk,
With my code FileName will be filled with the text enter in the appropriate place on the dialog, assuming the user clicked OK instead of Cancel. You then have do something with FileName, like .Save the file, as VBA does not do this for you; it only provides an intuitive interface to get the name/path. So you still need: ThisWorkbook.SaveAs FileName Nick "Cobbcouk" wrote in message ... Thanks for the quick response but im learning as i go with VBA. What do you mean? And where should I write the filename? I kind of understand the App.Get save as format but like I say, Im learning -- Cobbcouk ------------------------------------------------------------------------ Cobbcouk's Profile: http://www.excelforum.com/member.php...o&userid=32143 View this thread: http://www.excelforum.com/showthread...hreadid=531827 |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quick fix
To combine Nick's remarks with my solution, here is some code:
HTH -- AP '------------- Sub test() Dim fileName As String ActiveSheet.Protect "sports" fileName = Application.GetSaveAsFilename( _ InitialFileName:="U:\" & Format(Date, "dd_mm_yy") & "_sportsreturn", _ FileFilter:="Microsoft Excel Workbook (*.xls), *.xls" _ ) If fileName < False Then ActiveWorkbook.SaveAs fileName:=fileName End If End Sub '-------------- "NickHK" a écrit dans le message de ... Cobbcouk, With my code FileName will be filled with the text enter in the appropriate place on the dialog, assuming the user clicked OK instead of Cancel. You then have do something with FileName, like .Save the file, as VBA does not do this for you; it only provides an intuitive interface to get the name/path. So you still need: ThisWorkbook.SaveAs FileName Nick "Cobbcouk" wrote in message ... Thanks for the quick response but im learning as i go with VBA. What do you mean? And where should I write the filename? I kind of understand the App.Get save as format but like I say, Im learning -- Cobbcouk ------------------------------------------------------------------------ Cobbcouk's Profile: http://www.excelforum.com/member.php...o&userid=32143 View this thread: http://www.excelforum.com/showthread...hreadid=531827 |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Quick fix
Many Thanks All Its working only time will tell if the muppets using it will mess i up!!!!!!!!! Thanks again :)Ga -- Cobbcou ----------------------------------------------------------------------- Cobbcouk's Profile: http://www.excelforum.com/member.php...fo&userid=3214 View this thread: http://www.excelforum.com/showthread.php?threadid=53182 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Quick help | Excel Worksheet Functions | |||
Help quick | Excel Worksheet Functions | |||
I need quick help please! | Charts and Charting in Excel | |||
Quick question - quick answer about assigning shortcut keys | Excel Programming | |||
Quick VB Help | Excel Programming |