Results 1 to 6 of 6

Thread: saving a file

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2000
    Location
    W.Lafayette, In USA
    Posts
    37
    This may be easy but I have no clue. On my program I have a button which the user clicks and a pdf file comes up. My question is how do you allow the user to save a pdf file by a click of a button. I tried to do the common dialog box and just put the filename that they want to save in their folder but it doesn't save. Here is my code below:

    dlgSave.FileName = "16CM32MDOSummary(50).pdf"
    dlgSave.Flags = cdlOFNNoChangeDir Or cdlOFNHideReadOnly Or _
    cdlOFNOverwritePrompt Or cdlOFNPathMustExist
    dlgSave.Filter = "PDF Files (*.pdf)|*.pdf"
    dlgSave.FilterIndex = 1
    dlgSave.CancelError = True
    On Error Resume Next
    dlgSave.ShowSave

    If Err.Number <> 0 Then
    Exit Sub
    End If

    Please someone help me.
    There are numerous of files they want to be able to save in their directories.

    Thanks in advance

  2. #2
    Frenzied Member
    Join Date
    Jul 1999
    Posts
    1,800
    Im not sure, how to save a file, and I don't know how megatron hasn't been to this post yet, but this shows how to open the save prompt... http://www.vbsquare.com/tips/tip353.html

  3. #3
    PowerPoster BruceG's Avatar
    Join Date
    May 2000
    Location
    New Jersey (USA)
    Posts
    2,657
    The common dialog control does not actually save a file. You must do this in code using standard VB statements (you determine the name of the file to save after the user is done interacting with the dialog box, i.e., after the ShowSave method). Are you allowing the user to modify the pdf file or just view it? If the user can't modify the file, then you need not save it.
    "It's cold gin time again ..."

    Check out my website here.

  4. #4
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    to save it use the
    Code:
    Dim File as Integer
    File = FreeFile
    Open "File" for Binary as #File
    'use Put to write to Binary file
    Close #File
    you must have the data in a byte array to write it. if not, then you must figure out how to get it into one!

    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  5. #5

    Thread Starter
    Member
    Join Date
    Mar 2000
    Location
    W.Lafayette, In USA
    Posts
    37
    I want them to be able to save it into whatever directory they want it to be saved in. Just as a save as function do in windows.

  6. #6
    Guest
    If you are using a CommonDialog control, the path is stored in the filename property. So to save your file in that path, you would use:

    Code:
    Open CommonDialog1.filename For Binary As #1

Posting Permissions

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



Click Here to Expand Forum to Full Width