Consulting

Results 1 to 8 of 8

Thread: Opening CSV files disables / uninstalls add-ins

  1. #1
    VBAX Regular
    Joined
    Feb 2014
    Posts
    53
    Location

    Opening CSV files disables / uninstalls add-ins

    Every time I open a CSV file (by double-clicking it), Excel opens, but any add-ins I had installed are now uninstalled. I understand that CSV files cannot contain VBA code, but my code is in the add-in, so I had thought it should still be available. The add-ins I had installed don't even show up in the add-ins list. Furthermore, if I close Excel, then open an XLSX file, the add-ins are still disabled. I have to go back through the menu system and re-install them. This can't be normal behavior .... yet it happens to me on multiple computers... I even tried this with a very simple macro (saved as an XLAM add-in) that contains only a MsgBox. Can anyone else reproduce this? I can't imagine Microsoft intended add-ins to break every time a CSV file is opened...

    To recap:
    - If I open an XLSX file, then open a CSV file, the add-ins are available and work as intended on the CSV file.
    - If I open a CSV file directly, the add-ins are removed. They stay removed until I re-install them through the menu after restarting Excel.

  2. #2
    VBAX Guru Kenneth Hobs's Avatar
    Joined
    Nov 2005
    Location
    Tecumseh, OK
    Posts
    4,956
    Location
    Is it your addin or all? See if this helps: http://www.cpearson.com/Excel/CreateAddIn.aspx

  3. #3
    VBAX Regular
    Joined
    Feb 2014
    Posts
    53
    Location
    All add-ins. I just tried it from the sample XLA file in that article. Opening a CSV file directly disables it.

    What do add-ins do when you open a CSV file directly?

  4. #4
    VBAX Tutor
    Joined
    Jan 2008
    Posts
    266
    Location
    Can you post the code in the add-in?
    There is no answer to 'what an add-in does when you open a csv', it's how the code is written.

  5. #5
    VBAX Regular
    Joined
    Feb 2014
    Posts
    53
    Location
    When I asked what it does when you open a CSV, I meant 'what happens to the add-in itself?' The code inside the add-in is never run, so it's irrelevant. As I mentioned in the original post, I even tried it with nothing but a MsgBox, just to be sure.

    The problem is when opening Excel by opening a CSV, the entire add-in is disabled. So I'm wondering if that happens to everyone.

  6. #6
    VBAX Regular
    Joined
    Jun 2014
    Posts
    51
    Location
    Hello To All
    I am sorry for intruding your thread I am new in this and do not know how to start a ne post.
    Please see below a code that I am working on that I have a few problems:
    Sub opebcsv()
        Dim wbI As Workbook, wbO As Workbook
        Dim wsI As Worksheet
        Set wbI = ThisWorkbook
        Set wsI = wbI.Sheets("Sheet1") '<~~ Sheet where you want to import
        Set wbO = Workbooks.Open("C:\Users\volfs_000\Desktop\cradle-7200_4_5_new\Copy (10) of cradle7200_4_5_tom.csv")
        wbO.Sheets(1).Cells.Copy wsI.Cells
        wbO.Close SaveChanges:=False
        Kill (wbO)
    End Sub
    I was wondering if I can change the open file line to -- the way that I will get a window to choose a folder and than the file that will be pulled is the latest one.
    Second question is if I can set a creation range dates of the files wich are pulled

    Thank you

    Oleg

  7. #7
    VBAX Tutor
    Joined
    Jan 2008
    Posts
    266
    Location
    Quote Originally Posted by olegvolf View Post
    Hello To All
    I am sorry for intruding your thread I am new in this and do not know how to start a ne post.
    Please see below a code that I am working on that I have a few problems:
    Sub opebcsv()
        Dim wbI As Workbook, wbO As Workbook
        Dim wsI As Worksheet
        Set wbI = ThisWorkbook
        Set wsI = wbI.Sheets("Sheet1") '<~~ Sheet where you want to import
        Set wbO = Workbooks.Open("C:\Users\volfs_000\Desktop\cradle-7200_4_5_new\Copy (10) of cradle7200_4_5_tom.csv")
        wbO.Sheets(1).Cells.Copy wsI.Cells
        wbO.Close SaveChanges:=False
        Kill (wbO)
    End Sub
    I was wondering if I can change the open file line to -- the way that I will get a window to choose a folder and than the file that will be pulled is the latest one.
    Second question is if I can set a creation range dates of the files wich are pulled

    Thank you

    Oleg

    Like this?


    Sub opebcsv()
        Dim wbI As Workbook, wbO As Workbook
        Dim wsI As Worksheet
        Dim fd As FileDialog
        Dim objfl As Variant
        
        Set wbI = ThisWorkbook
        Set wsI = wbI.Sheets("Sheet1") '<~~ Sheet where you want to import
        
        Set fd = Application.FileDialog(msoFileDialogFilePicker)
        With fd
            .ButtonName = "Select"
            .AllowMultiSelect = True
            .Filters.Add "All Files", "*.*", 1
            .Title = "Select file"
            .InitialView = msoFileDialogViewDetails
            .Show
            For Each objfl In .SelectedItems
                Set wbO = Workbooks.Open(objfl)
            Next objfl
            On Error GoTo 0
        End With
        Set fd = Nothing
        
        wbO.Sheets(1).Cells.Copy wsI.Cells
        wbO.Close SaveChanges:=False
        Kill (wbO)
    End Sub
    Not sure what you mean with the second question.

  8. #8
    VBAX Regular
    Joined
    Jun 2014
    Posts
    51
    Location
    Quote Originally Posted by Ago View Post
    Like this?


    Sub opebcsv()
        Dim wbI As Workbook, wbO As Workbook
        Dim wsI As Worksheet
        Dim fd As FileDialog
        Dim objfl As Variant
        
        Set wbI = ThisWorkbook
        Set wsI = wbI.Sheets("Sheet1") '<~~ Sheet where you want to import
        
        Set fd = Application.FileDialog(msoFileDialogFilePicker)
        With fd
            .ButtonName = "Select"
            .AllowMultiSelect = True
            .Filters.Add "All Files", "*.*", 1
            .Title = "Select file"
            .InitialView = msoFileDialogViewDetails
            .Show
            For Each objfl In .SelectedItems
                Set wbO = Workbooks.Open(objfl)
            Next objfl
            On Error GoTo 0
        End With
        Set fd = Nothing
        
        wbO.Sheets(1).Cells.Copy wsI.Cells
        wbO.Close SaveChanges:=False
        Kill (wbO)
    End Sub
    Not sure what you mean with the second question.
    THANKS

    It works great.

Posting Permissions

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