PDA

View Full Version : Opening CSV files disables / uninstalls add-ins



cplindem
04-17-2014, 10:03 AM
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.

Kenneth Hobs
04-17-2014, 11:35 AM
Is it your addin or all? See if this helps: http://www.cpearson.com/Excel/CreateAddIn.aspx

cplindem
04-17-2014, 12:11 PM
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?

Ago
04-18-2014, 12:31 AM
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.

cplindem
04-18-2014, 08:37 AM
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.

olegvolf
06-20-2014, 03:05 AM
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

Ago
06-23-2014, 01:20 AM
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.

olegvolf
07-01-2014, 12:16 PM
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.