Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello everyone,
I am using the API GetSaveFileName and all seems to be fine except for when I press escape to cancel the dialog. I recieve a message that code processing has been interrupted and asked if I would like to debug or cancel. Anyone have any ideas what I can do to get around that? I am using the code from http://vbnet.mvps.org/index.html?cod...avedlghook.htm Public Function ShowSave(Title As String, InitialPath As String, InitialFilename As String) As String Dim sFilters As String Dim pos As Long Dim buff As String Dim sLongname As String Dim sShortname As String 'if first time through set the appropriate OFN size If OSV_VERSION_LENGTH = 0 Then Call SetOSVersion 'filters for the dialog sFilters = "Excel Files" & vbNullChar & "*.XLS" & vbNullChar & vbNullChar DialogCaption = Title With OFN .nStructSize = OSV_VERSION_LENGTH .hwndOwner = 0 .sFilter = sFilters .nFilterIndex = 2 .sFile = InitialFilename & Space$(1024) & vbNullChar & vbNullChar .nMaxFile = Len(.sFile) .sDefFileExt = "xls" & vbNullChar & vbNullChar .sFileTitle = vbNullChar & Space$(512) & vbNullChar & vbNullChar .nMaxTitle = Len(OFN.sFileTitle) .sInitialDir = InitialPath & vbNullChar & vbNullChar .sDialogTitle = "Blah Blah Blah" .flags = OFS_FILE_SAVE_FLAGS Or _ OFN_ENABLESIZING Or _ OFN_ENABLEHOOK .fnHook = FARPROC(AddressOf OFNHookProc) End With 'call the API If GetSaveFileName(OFN) Then buff = Trim$(Left$(OFN.sFile, Len(OFN.sFile) - 2)) ShowSave = Trim(buff) End If End Function Excel 2000-2003 TIA |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
This is using callback code that as far as I can ascertain, is simply used
to enable positioning of the window. Why don't you just use Excel's built-in GetSaveAsFilename method? -- HTH Bob Phillips (remove nothere from email address if mailing direct) "AMDRIT" wrote in message ... Hello everyone, I am using the API GetSaveFileName and all seems to be fine except for when I press escape to cancel the dialog. I recieve a message that code processing has been interrupted and asked if I would like to debug or cancel. Anyone have any ideas what I can do to get around that? I am using the code from http://vbnet.mvps.org/index.html?cod...avedlghook.htm Public Function ShowSave(Title As String, InitialPath As String, InitialFilename As String) As String Dim sFilters As String Dim pos As Long Dim buff As String Dim sLongname As String Dim sShortname As String 'if first time through set the appropriate OFN size If OSV_VERSION_LENGTH = 0 Then Call SetOSVersion 'filters for the dialog sFilters = "Excel Files" & vbNullChar & "*.XLS" & vbNullChar & vbNullChar DialogCaption = Title With OFN .nStructSize = OSV_VERSION_LENGTH .hwndOwner = 0 .sFilter = sFilters .nFilterIndex = 2 .sFile = InitialFilename & Space$(1024) & vbNullChar & vbNullChar .nMaxFile = Len(.sFile) .sDefFileExt = "xls" & vbNullChar & vbNullChar .sFileTitle = vbNullChar & Space$(512) & vbNullChar & vbNullChar .nMaxTitle = Len(OFN.sFileTitle) .sInitialDir = InitialPath & vbNullChar & vbNullChar .sDialogTitle = "Blah Blah Blah" .flags = OFS_FILE_SAVE_FLAGS Or _ OFN_ENABLESIZING Or _ OFN_ENABLEHOOK .fnHook = FARPROC(AddressOf OFNHookProc) End With 'call the API If GetSaveFileName(OFN) Then buff = Trim$(Left$(OFN.sFile, Len(OFN.sFile) - 2)) ShowSave = Trim(buff) End If End Function Excel 2000-2003 TIA |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Because that would have been better. Seriously, I didn't know about it.
I just put it in place and the code is happier now. Thanks "Bob Phillips" wrote in message ... This is using callback code that as far as I can ascertain, is simply used to enable positioning of the window. Why don't you just use Excel's built-in GetSaveAsFilename method? -- HTH Bob Phillips (remove nothere from email address if mailing direct) "AMDRIT" wrote in message ... Hello everyone, I am using the API GetSaveFileName and all seems to be fine except for when I press escape to cancel the dialog. I recieve a message that code processing has been interrupted and asked if I would like to debug or cancel. Anyone have any ideas what I can do to get around that? I am using the code from http://vbnet.mvps.org/index.html?cod...avedlghook.htm Public Function ShowSave(Title As String, InitialPath As String, InitialFilename As String) As String Dim sFilters As String Dim pos As Long Dim buff As String Dim sLongname As String Dim sShortname As String 'if first time through set the appropriate OFN size If OSV_VERSION_LENGTH = 0 Then Call SetOSVersion 'filters for the dialog sFilters = "Excel Files" & vbNullChar & "*.XLS" & vbNullChar & vbNullChar DialogCaption = Title With OFN .nStructSize = OSV_VERSION_LENGTH .hwndOwner = 0 .sFilter = sFilters .nFilterIndex = 2 .sFile = InitialFilename & Space$(1024) & vbNullChar & vbNullChar .nMaxFile = Len(.sFile) .sDefFileExt = "xls" & vbNullChar & vbNullChar .sFileTitle = vbNullChar & Space$(512) & vbNullChar & vbNullChar .nMaxTitle = Len(OFN.sFileTitle) .sInitialDir = InitialPath & vbNullChar & vbNullChar .sDialogTitle = "Blah Blah Blah" .flags = OFS_FILE_SAVE_FLAGS Or _ OFN_ENABLESIZING Or _ OFN_ENABLEHOOK .fnHook = FARPROC(AddressOf OFNHookProc) End With 'call the API If GetSaveFileName(OFN) Then buff = Trim$(Left$(OFN.sFile, Len(OFN.sFile) - 2)) ShowSave = Trim(buff) End If End Function Excel 2000-2003 TIA |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
GetSaveFileName across mixed language network | Excel Programming |