![]() |
GetSaveAsFilename
Can anyone advise me a method to divert/re-program the 'Save' button
on the GetSaveAsFilename dialog to run my own comma delimited file saving routine, I need to save specific areas of text values and formulas from an Excel 2000 worksheet in XP, or will I need to recreate a facsimile of the file SaveAs form. Thanks for any help Oswald |
GetSaveAsFilename
Hi Oswald
In Excel 2003 I created the code below. As far as I know there are no changes in the VBA between 2002 and 2003. Sub OswladSave() Dim strFilename As String Dim lngRow As Long Dim lngCol As Long Dim lngFree As Long Dim strRow As String strFilename = Application.GetSaveAsFilename ' When cancel is clikced If strFilename = "False" Then Exit Sub lngFree = FreeFile Open strFilename For Output As lngFree For lngRow = 1 To Selection.Rows.Count strRow = "" For lngCol = 1 To Selection.Columns.Count If lngCol 1 Then strRow = strRow & "," End If strRow = strRow & _ CStr(Selection.Cells(lngRow, lngCol).Value) Next Print #lngFree, strRow Next Close #lngFree End Sub HTH, Wouter |
GetSaveAsFilename
On 10 Mar, 20:10, Wouter HM wrote:
HiOswald In Excel 2003 I created the code below. As far as I know there are no changes in the VBA between 2002 and 2003. Sub OswladSave() * * Dim strFilename As String * * Dim lngRow As Long * * Dim lngCol As Long * * Dim lngFree As Long * * Dim strRow As String * * strFilename = Application.GetSaveAsFilename * * ' When cancel is clikced * * If strFilename = "False" Then Exit Sub * * lngFree = FreeFile * * Open strFilename For Output As lngFree * * For lngRow = 1 To Selection.Rows.Count * * * * strRow = "" * * * * For lngCol = 1 To Selection.Columns.Count * * * * * * If lngCol 1 Then * * * * * * * * strRow = strRow & "," * * * * * * End If * * * * * * strRow = strRow & _ * * * * * * * * * * * * * CStr(Selection.Cells(lngRow, lngCol).Value) * * * * Next * * * * Print #lngFree, strRow * * Next * * Close #lngFree End Sub HTH, Wouter Wouter you are a gem, thank you very much, your code has the simple elegance I was looking for, this isn't commercial but I will honour you as the core donor in my VB code. Oswald |
All times are GMT +1. The time now is 09:37 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com