October 23, 2016
Hot Topics:

Anything to declare?

  • November 19, 2002
  • By Sam Huggill
  • Send Email »
  • More Articles »

And finally, the following code will help you access the save as dialog:

  lStructSize As Long 
  hwndOwner As Long 
  hInstance As Long 
  lpstrFilter As String 
  lpstrCustomFilter As String 
  nMaxCustFilter As Long 
  nFilterIndex As Long 
  lpstrFile As String 
  nMaxFile As Long 
  lpstrFileTitle As String 
  nMaxFileTitle As Long 
  lpstrInitialDir As String 
  lpstrTitle As String 
  flags As Long 
  nFileOffset As Integer 
  nFileExtension As Integer 
  lpstrDefExt As String 
  lCustData As Long 
  lpfnHook As Long 
  lpTemplateName As String 
End Type 
Private Declare Function_
  GetSaveFileName Lib_
  "comdlg32.dll" _
Alias "GetSaveFileNameA"_
  (pOpenfilename As OPENFILENAME)_
  As Long 
Private Sub Command1_Click() 
ofn.lStructSize = Len(ofn) 
ofn.hwndOwner = Form1.hWnd 
ofn.hInstance = App.hInstance 
ofn.lpstrFilter = "Text Files_
  (*.txt)" + Chr$(0) + _
  "*.txt" + Chr$(0)_
  + "Rich Text Files (*.rtf)_
  " + Chr$(0) _
  + "*.rtf" + Chr$(0) 
ofn.lpstrFile = Space$(254) 
ofn.nMaxFile = 255 
ofn.lpstrFileTitle = Space$(254) 
ofn.nMaxFileTitle = 255 
ofn.lpstrInitialDir = CurDir 
ofn.lpstrTitle = "Dialog_
ofn.flags = 0 
Dim a 
a = GetSaveFileName(ofn) 
If (a) Then 
MsgBox "File to Save: "_
  + Trim$(ofn.lpstrFile) 
'FileSave Stuff Here 
MsgBox "Cancel was pressed" 
End If 
End Sub  

That's it! Easy eh. No need for large file sizes because of bulky .ocx files, just use an API call!

Page 4 of 4

Comment and Contribute


(Maximum characters: 1200). You have characters left.



Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Sitemap | Contact Us

Thanks for your registration, follow us on our social networks to keep up-to-date
Rocket Fuel