Results 1 to 5 of 5

Thread: Problem with excel

  1. #1

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    3

    Problem with excel

    I have this spreadsheet that was set up by someone who has now left my job and just wondering if some one here could help
    most likely something simple but this is way over my head any head appreciated

    VB Code:
    1. Private Sub Workbook_BeforeClose(Cancel As Boolean)
    2. Dim i, j As Integer
    3. Dim texte As String
    4. Dim Wksht As Worksheet
    5.  
    6. On Error Resume Next 'Fermeture de Data Passdown
    7. Workbooks(Range("NameDataPassdown").Value).Close SaveChanges:=False
    8. On Error GoTo 0
    9. If Userallowed = False Then Exit Sub
    10. Application.ScreenUpdating = False
    11. If Range("Freeaccess").Value = True Then
    12. Or ActiveWorkbook.ReadOnly Then Exit Sub
    13. SortieSansEnregistrement = True
    14. Sheets("LOG").Select
    15. On Error Resume Next
    16. ActiveSheet.ShowAllData
    17. Range("RefID").End(xlDown).Select
    18. On Error GoTo 0
    19. Call Enregistrement 'Affichage feuille warning + enregistrement
    20. If MsgBox("Passdown is already saved." & Chr(10) & _
    21.     "Do you want to create a new copy in the Free To Use Folder ?" & Chr(10) & Chr(10) & _
    22.     "A copy must be created at the end of each shift.", vbYesNo) = vbNo Then Exit Sub
    23. 'Je cache les feuilles non free to use + administrator pour access a tous
    24. Call AffichFeuillesUtilisateurs
    25. 'J'autorise l'acces de tous au fichier dans Folder "Free to use" avant de sauvegarder
    26. Range("Freeaccess").Value = 1
    27. 'Sauvegarde d'une copie actualisee dans Folder "Free to use"
    28. ActiveWorkbook.SaveAs Filename:= _
    29.     Range("filename").Value & " Passdown by " & Range("Currentuser").Value & " " & Format(Now, "dd-mm-yy hh-mm-ss") & ".xls"
    some is in french but the line
    Or ActiveWorkbook.ReadOnly Then Exit Sub
    comes up in red when attempting to debug

    regards

    micks

  2. #2
    Fanatic Member Jumpercables's Avatar
    Join Date
    Jul 2005
    Location
    Colorado
    Posts
    592

    Re: Problem with excel

    Red as in a breakpoint? Or Red as an error occurs on that line? If Error whats the error your getting?

    C# - .NET 1.1 / .NET 2.0

    "Take everything I say with a grain of salt, sometimes I'm right, sometimes I'm wrong but in the end we've both learned something."
    _____________________
    Regular Expressions Library
    Connection String
    API Functions
    Database FAQ & Tutorial

  3. #3

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    3

    Re: Problem with excel

    thanks for reply

    previously when we'd close this spreadsheet we'd a questions asking do we want to save in another location for access as its locked when editing

    now when we close we get a
    "compile error:syntax error"
    then visual basic editor opens and the first line "Private Sub Workbook_BeforeClose(Cancel As Boolean)" is highlighted in yellow and the line
    "Or ActiveWorkbook.ReadOnly Then Exit Sub" is highlighted as if cursor is dragged across it and then when clicked on its the only line in red.i assumed a problem but maybe a breakpoint i dont know anything about this .

    regards

  4. #4
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: Problem with excel

    It would be red as in an error.

    As there is no matching "End If" for the previous line, I would guess that they are supposed to be combined, eg:
    VB Code:
    1. If Range("Freeaccess").Value = True _
    2. Or ActiveWorkbook.ReadOnly Then Exit Sub

    Oh, and welcome to VBForums micks!

  5. #5

    Thread Starter
    New Member
    Join Date
    Jan 2006
    Posts
    3

    Re: Problem with excel

    now when i put in your line i get"compile error:expected then or goto"
    cheers

    Thanks a mill
    worked a treat i didnt leave a space before the _ so got an error

    once again fair play

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