help with runtime error 13 mismatch

dodgeking3171

New Member
Joined
Feb 6, 2014
Messages
39
Hey guys I have the following code, the highlighted line seems to give me a runtime error 13 mismatch. i had a few others that i could figure out but this one has me stumped.

the part that is giving me the trouble right now is . Workbooks.Open Left(Path, Len(Path) - 5) & FileName

also, can someone explain what the causes the runtime error? ive never had ths problem before

thanks guys the whole code is longer, but this leads up to the problem im having right now

Code:
Private Sub Workbook_Open()





Dim printquotes As String


Dim OrigDate As Date


letmesave = True






OrigDate = ActiveSheet.Range("n2").Value








If CDate(Now) > CDate(OrigDate) + 23 Then


MsgBox " This application is about to expire, please renew"


End If
If CDate(Now) > CDate(OrigDate) + 25 Then


MsgBox " PAY ATTENTION TO THE NEXT PROMPT"




printquotes = MsgBox("This application has expired.  Would you like to print all quotes?" _
& vbNewLine & "all quotes will be saved on the desktop under expired quotes" _
& vbNewLine & "NOTE ALL QUOTES WILL BE CLEANED", vbYesNo, Expired)


MkDir "C:\Users\PARTS1\Desktop\Expired Quotes"
If printquotes = vbYes Then GoTo line2:
If printquotes = vbNo Then GoTo line3:
End If


      'Prints all sheets
                                                    
line2:
                                                    Dim wb As Workbook, ws As Worksheet
                                                    Dim FileName As String, Path As String
                                                    Dim skip As String
      
     
    
                                                    Set wb = ActiveWorkbook
                                                    Set ws = ActiveSheet


                                                   Path = "\\BIG-BERTHA-PC\Data\Customer Estimate Folder\Quotes\*.xls"
   
                                                   FileName = Dir(Path, vbNormal)
                                                   Application.DisplayAlerts = False
                                                   Do Until FileName = ""
                                                   [COLOR=#ff0000]Workbooks.Open Left(Path, Len(Path) - 5) & FileName[/COLOR]
0                                                 Set wb = ActiveWorkbook
                                                    For Each ws In wb.Worksheets
            
          
                                                    skip = ws.Range("k4")
        
                                                    If IsEmpty(skip) Then GoTo line1:
        
                                                    If skip = "0" Then GoTo line1:
                                                     
                                                    If Not (skip) = "" Then
      
                                                    ws.PrintOut
    
line1:
                                                    End If
  
                                                  Next
    
                                                   wb.Close
    
                                                    FileName = Dir()
                                                   Loop
                                                    Application.DisplayAlerts = True
                                                 


line3:
[\code]
 
Last edited:

MARK858

MrExcel MVP
Joined
Nov 12, 2010
Messages
11,451
Office Version
365, 2010
Platform
Windows, Mobile
Sorry guys i dont seem to know how to do the tag option
Forward slash not backslash or select your code and click the # button.
 

Forum statistics

Threads
1,081,415
Messages
5,358,533
Members
400,502
Latest member
price83

Some videos you may like

This Week's Hot Topics

  • VBA (Userform)
    Hi All, I just would like to know why my code isn't working. Here is my VBA code: [CODE=vba]Private Sub OKButton_Click() Dim i As Integer...
  • List box that changes fill color
    Hello, I have gone through so many pages trying to figure this out. I have a 2020 calendar that depending on the day needs to have a certain...
  • Remove duplicates and retain one. Cross-linked cases
    Hi all I ran out of google keywords to use and still couldn't find a reference how to achieve the results of a single count. It would be great if...
  • VBA Copy and Paste With Duplicates
    Hello All, I'm in need of some input. My VBA skills are sub-par at best. I've assembled this code from basic research and it works but is...
  • Macro
    is it possible for a macro to run if the active cell value is different to the value above it
  • IF DATE and TIME
    I currently use this to check if date has passed but i also need to set a time on it too. Is it possible? [CODE=vba]=IF(B:B>TODAY(),"Not...
Top