Consulting

Results 1 to 7 of 7

Thread: Generate a message to Save and Not Open when downloading a file

  1. #1
    VBAX Regular
    Joined
    Feb 2009
    Posts
    35
    Location

    Generate a message to Save and Not Open when downloading a file

    Hi

    I have an excel file that I place on a web site and a lot of users download this file for a specific use.
    I heard that a lot of problems occur because the users are not used to Save the file to their own disk before starting to edit it. They Simply press the Open button instead of the Save button when downloading the file.

    I want to generate a message that will pop the first time that they open the file. The message will tell them "Please save the file to you own PC first and only then open it for edit".

    However:
    1- I don't want them to get this message every time they open the file.
    2- I thought of inserting a dummy value in a specific cell when first opening the file just to indicate to myself that the file has already been opened once so the message will pop only in the 1st opening. The next opening will see this value and message will not pop. But I need to save the file for them in order to place this indication for the next opening.

    Any other ideas how to overcome this problem ??

    Thanks
    Asi

  2. #2
    VBAX Mentor MaximS's Avatar
    Joined
    Sep 2008
    Location
    Stoke-On-Trent
    Posts
    360
    Location
    why not to:
    1. Implement a pop-up on your website whith 2 behaviours:
    A) link has been clicked before pop-up will not appear and file will be open
    B) link hasn't been clicked before pop-up will show instruction

    2. Put instruction above the link on your website

  3. #3
    VBAX Regular
    Joined
    Feb 2009
    Posts
    35
    Location
    I don't think I fully understood your suggestion but:
    1. There are already instructions on the wed site to save the file before working on it and users does not seem to follow the instructions.
    2. I can't make any change on the web site. it's not my department and I don't think they will do that.
    3. I got instructions from above to implement the change on the Excel file itself meaning - generate a message the first time it opens.

    any help on how to do that in VBA ?

    Thanks
    Asi

  4. #4
    VBAX Mentor MaximS's Avatar
    Joined
    Sep 2008
    Location
    Stoke-On-Trent
    Posts
    360
    Location
    try that in your workbook:

    [vba]
    Private Sub Workbook_BeforeClose(Cancel As Boolean)

    Dim wbcounter As Long
    'you can change range and worksheet to someting user will not use
    'or want change i.e. some hidden sheet
    wbcounter = ThisWorkbook.Worksheets(Sheet1).Range("IV1").Value
    ThisWorkbook.Worksheets(Sheet1).Range("IV1").Value = wbcounter + 1
    ThisWorkbook.Save
    End Sub

    Private Sub Workbook_Open()
    Dim Err As String
    Dim wbcounter As Long

    'you can change range and worksheet to someting user will not use
    'or want change i.e. some hidden sheet
    wbcounter = ThisWorkbook.Worksheets(Sheet1).Range("IV1").Value
    If wbcounter > 0 Then
    Err = MsgBox("Please save the file on your PC", _
    vbCritical + vbOKOnly, "Please save the file on your PC")
    End If
    End Sub
    [/vba]

  5. #5
    VBAX Regular
    Joined
    Feb 2009
    Posts
    35
    Location
    1. I think that if I open the file from the Web so when I do the Save in the WorkBook_BeforeClose event - the document is saved on the Web. I do not think it will work (permissions etc...)
    I need to check where it is located before saving.

    2. In the WorkBook_open event you specified
    [VBA]
    If wbcounter > 0 Then
    [/VBA]
    Isn't it supose to be

    [VBA]
    If
    wbcounter = 0 Then
    [/VBA]


  6. #6
    VBAX Mentor MaximS's Avatar
    Joined
    Sep 2008
    Location
    Stoke-On-Trent
    Posts
    360
    Location
    of course you can change:

    [VBA]ThisWorkbook.Save[/VBA]

    to

    [VBA]ThisWorkbook.SaveAs[/VBA]

    with path of your choice and your are right wbcounter should be set to 0

  7. #7
    VBAX Regular
    Joined
    Feb 2009
    Posts
    35
    Location
    Thanks ...
    I used only the Workbook_BeforeClose event which generates a message asking the user to Save the file first if the file is unsaved and it's the 1st time.
    It works OK...

    However, this message pops when the file is closed.
    I prefer to check via Worksheet_Change event on one of the sheets if the file is located on the web and if so then generate the message.

    what I did was:
    [VBA]
    Private Sub Worksheet_Change(ByVal Target As Range)

    If Left(ThisWorkbook.Name, 4) = "http" Or Left(ThisWorkbook.path, 4) = "http" Then
    Response = MsgBox("Please Save the file on your own PC before you continue", _
    vbCritical + vbOKOnly, "Please save file")

    End If

    End Sub
    [/VBA]

    Will it work when Uploading the file on the web ?
    Is there a way to find out if the file is on the Web ?
    Is there a way to find out if the file is on your PC ?

    Thanks

Posting Permissions

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