+ Reply to Thread
Results 1 to 4 of 4

Method 'Open of object 'Workbooks'Failed

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-23-2015
    Location
    Sweden
    MS-Off Ver
    2013
    Posts
    109

    Method 'Open of object 'Workbooks'Failed

    Hi guys I have a code that filter a filename then try to open a file

    
    
    Sub MergeNoTransAndLang()
    
    
    Dim myPath As String
    Dim StrCurrentfile As String
    Dim StrFName As String
    Dim myLangFile As String
    Dim intResult As Integer
    
    
    Application.DisplayAlerts = True
    
    
    
    
    intResult = Application.FileDialog(msoFileDialogFolderPicker).Show
    
    
    If intResult = 0 Then
    
    
        MsgBox "User pressed cancel macro will stop!"
    
    
    Exit Sub
    
    
    Else
    
    
    strDocPath = Application.FileDialog(msoFileDialogFolderPicker).SelectedItems(1) & "\"
    
    
    End If
    
    
    
    
    StrCurrentfile = Dir(strDocPath & "*NoTrans.xls")
    Do While StrCurrentfile <> ""
    
    
    
    
    myNoTransfile = strDocPath & StrCurrentfile
    
    
    myLangFile = Replace(StrCurrentfile, "_NoTrans", "")
    
    
    MsgBox myLangFile
    
    
    
    
    
    
    Set myLangFileN = Workbooks.Open(strDocPath & StrCurrentfile)
    Columns(1).Select
    Selection.Copy
    
    
    Set noLangFilen = Workbooks.Open(strDocPath & myLangFile)
    noLangFilen.Sheets.Add(After:=noLangFilen.Sheets(noLangFilen.Sheets.Count)).Name = "WordNotTrans"
    ActiveSheet.Paste
    
    
    
    
    
    
    ActiveWorkbook.Worksheets("Translated").Activate
    Rows("1:1").Select
    Selection.EntireRow.Hidden = False
    
    
    
    
    ActiveWorkbook.Worksheets("WordNotTrans").Activate
    
    
    Dim s As String
    Dim Current As Worksheet
    For Each Current In Worksheets
    For Each C In ActiveSheet.UsedRange
    If C.Interior.ColorIndex = 3 Then
    s = C.Address
    C.Copy Sheets("Translated").Range(s)
    End If
    Next
    Next
    Worksheets("WordNotTrans").Delete
    Application.DisplayAlerts = False
    myLangFileN.Close SaveChanges:=False
    noLangFilen.CheckCompatibility = False
    noLangFilen.Close SaveChanges:=True
    
    
    StrCurrentfile = Dir
    
    
    
    
    Loop
    
    
    
    
    End Sub
    I get this error




    the file exists and have exact that name.

    Could someone help me?

    Thank you in advance

  2. #2
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Method 'Open of object 'Workbooks'Failed

    The Dir Argument can only be the strDocPath
    If I've helped you, please consider adding to my reputation - just click on the liitle star at the left.

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~(Pride has no aftertaste.)

    You can't do one thing. XLAdept

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~aka Orrin

  3. #3
    Forum Contributor
    Join Date
    02-23-2015
    Location
    Sweden
    MS-Off Ver
    2013
    Posts
    109

    Re: Method 'Open of object 'Workbooks'Failed

    still doesnt work..

  4. #4
    Forum Guru xladept's Avatar
    Join Date
    04-14-2012
    Location
    Pasadena, California
    MS-Off Ver
    Excel 2003,2010
    Posts
    12,378

    Re: Method 'Open of object 'Workbooks'Failed

    What happens?

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] run-time error '1004' method 'open' of object 'workbooks' failed
    By mattress58 in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 05-03-2016, 06:24 PM
  2. [SOLVED] method 'open text' of object 'workbooks' failed
    By tina in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 10-23-2013, 11:53 AM
  3. method 'open text' of object 'workbooks' failed
    By richieniel in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-23-2013, 10:42 AM
  4. [SOLVED] Method 'open' of object 'workbooks' failed
    By crunchKH in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-01-2013, 09:13 PM
  5. Method 'Open' of object 'Workbooks' failed from within browser window
    By ramiro in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-07-2008, 12:08 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1