+ Reply to Thread
Results 1 to 4 of 4

Prompt for SaveAsDialog with file type preset.

Hybrid View

  1. #1
    invictus1964
    Guest

    Prompt for SaveAsDialog with file type preset.

    I want to prompt the user for a save as file name and defualt the file type
    to csv. I am trying
    Application.Dialogs(xlDialogSaveAs).Show Arg2:=xlCSV
    result: saves file as csv then code is interrupted
    also tried
    Filename = Application.GetSaveAsFilename( _
    fileFilter:="Comma Seperated Values (*.csv), *.csv")
    result: no interruption but does not save file and cannot recall name using
    ActiveWorkbook.SaveAs





  2. #2
    Forum Contributor
    Join Date
    11-16-2004
    Posts
    282
    Try this code:

    Sub a_saveFile()
    Dim myFile

    myFile = Application.GetSaveAsFilename( _
    fileFilter:="Comma Seperated Values (*.csv), *.csv")
    ActiveWorkbook.SaveAs myFile
    MsgBox "File saved as : " & myFile
    End Sub

    Hope this helps,
    theDude

  3. #3
    Dave Peterson
    Guest

    Re: Prompt for SaveAsDialog with file type preset.

    maybe...

    dim myFileName as Variant
    myfilename = application.getsaveasfilename("comma separated values, *.csv")
    if myfilename = false then
    'user hit cancel
    else
    activeworkbook.saveas filename:=myfilename, fileformat:=xlCSV
    end if

    ..getsaveasfilename won't do the save, but it'll give you the name--so you can do
    your own save.

    invictus1964 wrote:
    >
    > I want to prompt the user for a save as file name and defualt the file type
    > to csv. I am trying
    > Application.Dialogs(xlDialogSaveAs).Show Arg2:=xlCSV
    > result: saves file as csv then code is interrupted
    > also tried
    > Filename = Application.GetSaveAsFilename( _
    > fileFilter:="Comma Seperated Values (*.csv), *.csv")
    > result: no interruption but does not save file and cannot recall name using
    > ActiveWorkbook.SaveAs


    --

    Dave Peterson

  4. #4
    Craig
    Guest

    Re: Prompt for SaveAsDialog with file type preset.

    I use this
    /code
    Sub CSVName()
    FullFileName = Application.GetSaveAsFilename("", "CSV (Comma
    delimited)(*.csv),*.csv", 1, "Save As *.csv")
    If FullFileName <> "False" Then
    ActiveWorkbook.SaveAs Filename:=FullFileName, FileFormat:=xlCSV
    End If
    End Sub
    /code

    Craig


    "invictus1964" <invictus1964@discussions.microsoft.com> wrote in message
    news:9DF5CA05-5DBC-47F6-9F4F-27685BE3A51E@microsoft.com...
    > I want to prompt the user for a save as file name and defualt the file

    type
    > to csv. I am trying
    > Application.Dialogs(xlDialogSaveAs).Show Arg2:=xlCSV
    > result: saves file as csv then code is interrupted
    > also tried
    > Filename = Application.GetSaveAsFilename( _
    > fileFilter:="Comma Seperated Values (*.csv), *.csv")
    > result: no interruption but does not save file and cannot recall name

    using
    > ActiveWorkbook.SaveAs
    >
    >
    >
    >




+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1