Dannemann


Hi people!
I'm having trouble in opening a dialog box in VBA. I need that when i click in a form button, the save as dialog appears to save a txt file
im not finding not on google and other searches engines
please somebody help me.. im looking this since yesterday
thanks folks
a hug



Re: Microsoft Project 2003 (How to open a save as dialog box with a macro?)

MyLady


Hey,

Application.Dialogs(xlDialogSaveAs).Show

Best Regards

Cathrine






Re: Microsoft Project 2003 (How to open a save as dialog box with a macro?)

Dannemann

its not working

Private Sub ToggleButton1_Click()
Application.Dialogs(xlDialogSaveAs).Show
End Sub

look the code that is working.. but this is for open file dialog

ive create a form, later a button in VBA editor of ms project 2003


Private Declare Function GetOpenFileName Lib "comdlg32.dll" Alias _
"GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long

Private Type OPENFILENAME
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

Public Function ShowOpen(Filter As String, InitialDir As String, DialogTitle As String) As String
Dim OFName As OPENFILENAME

OFName.lStructSize = Len(OFName) 'Set the structure size.
OFName.hwndOwner = 0 'Set the owner window.
OFName.lpstrFilter = Filter 'Set the filter.
OFName.nMaxFile = 255 'Set the maximum number of chars.
OFName.lpstrFile = Space(254) 'Create a buffer.
OFName.lpstrFileTitle = Space$(254) 'Create a buffer.
OFName.nMaxFileTitle = 255 'Set the maximum number of chars.
OFName.lpstrInitialDir = InitialDir 'Set the initial directory.
OFName.lpstrTitle = DialogTitle 'Set the dialog title.
OFName.flags = 0 'No extra flags.

'Show the 'Open File' dialog.
If GetOpenFileName(OFName) Then
ShowOpen = Trim(OFName.lpstrFile)
Else
ShowOpen = ""
End If
End Function

Private Sub ToggleButton1_Click()
Dim Filter As String
Dim InitialDir As String
Dim DialogTitle As String
Dim OutputStr As String

Filter = "Concepta Consultoria"
InitialDir = "C:\"
DialogTitle = "Escolha a pasta onde deseja salvar o arquivo:"
OutputStr = ShowOpen(Filter, InitialDir, DialogTitle)
MsgBox OutputStr
End Sub







Re: Microsoft Project 2003 (How to open a save as dialog box with a macro?)

ADG

Hi

I don't have a copy of Project, but I guess you need to change the constant in Application.Dialogs(xlDialogSaveAs).Show as xlDialogSaveAs is an Excel Constant. You should get a prompt as you type the openning bracket with the possible values.





Re: Microsoft Project 2003 (How to open a save as dialog box with a macro?)

Dannemann

really thanks people
ive solve this way

Application.Dialogs(FileSaveAs).Show


but when a close the window an error occurs
somebody knows how to fix it