Renaming files now obviously stops code working
Results 1 to 4 of 4

Thread: Renaming files now obviously stops code working
Thanks Thanks: 0 Likes Likes: 0

  1. #1
    Board Regular
    Join Date
    Nov 2010
    Posts
    2,328
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Renaming files now obviously stops code working

    Hi,
    I have this code in use which when in my database & i press its button the corresponding invoice is then shown.
    At the time the invoice were saved like this,
    1.pdf
    2.pdf
    3.pdf
    Code:
    Private Sub OpenInvoice_Click()
    
        Const FILE_PATH As String = "C:\Users\Ian\Desktop\REMOTES ETC\DR COPY INVOICES\"
        
        If txtInvoiceNumber = "N/A" Or Len(txtInvoiceNumber) = 0 Then
                    MsgBox "Invoice N/A For This Customer", vbExclamation, "N/A INVOICE NOTICE"
        Else
            If Len(Dir(FILE_PATH & txtInvoiceNumber.Value & ".pdf")) = 0 Then
                If MsgBox("Would You Like To Open The Folder ?", vbCritical + vbYesNo, "Warning Invoice is Missing.") = vbYes Then
                    CreateObject("Shell.Application").Open ("C:\Users\Ian\Desktop\REMOTES ETC\DR COPY INVOICES\")
                End If
            Else
                CreateObject("Shell.Application").Open (FILE_PATH & txtInvoiceNumber.Value & ".pdf")
            End If
        End If
    End Sub
    I have just had to rename all the invoices so now see below
    1.pdf becomes 1_04_03_2015.pdf
    2.pdf becomes 2_07_03_2015.pdf
    3.pdf becomes 3_02_04_2015.pdf

    So the invoice number is now saved with the date it was created afterwards.

    Because of this i now see the msgbox pop up saying Warning invoice is missing,would you like to open the folder.

    My question is how can i fix this if the date will be different for each invoice.

    Thanks
    I have learning difficulties so please be patient if i'm slow on the uptake,Thanks Very Much...

  2. #2
    Board Regular
    Join Date
    Oct 2009
    Location
    Midlands, UK
    Posts
    7,509
    Post Thanks / Like
    Mentioned
    17 Post(s)
    Tagged
    3 Thread(s)

    Default Re: Renaming files now obviously stops code working

    Use "*.pdf" rather than ".pdf" and see if that works.

  3. #3
    Board Regular
    Join Date
    Oct 2009
    Location
    Midlands, UK
    Posts
    7,509
    Post Thanks / Like
    Mentioned
    17 Post(s)
    Tagged
    3 Thread(s)

    Default Re: Renaming files now obviously stops code working

    You will need to use the Dir command to get the string then pass it to the shell if you want to do it that way. The shell i dont think will like wildcards.

  4. #4
    Board Regular
    Join Date
    Nov 2010
    Posts
    2,328
    Post Thanks / Like
    Mentioned
    6 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Renaming files now obviously stops code working

    Hi,
    I have tried the new code as mentioned in post #2 but not i dont even see the msgbox pop up.
    With regards post #3 what / or how do i go about that
    I have learning difficulties so please be patient if i'm slow on the uptake,Thanks Very Much...

Some videos you may like

User Tag List

Tags for this Thread

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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