I am trying to populate a list box with the open files. The whole procedure will export the selected sheets from the existing file to another workbook and save it with a date time stamp appended into the same directory. It builds this export name and file from items in list boxes on a form.
The macro will be running from Personal.XLSB; the problem is that this becomes the active workbook and the exported file inherits the path and file name from it. I want to build the export name by letting the use pick a file name from the list box BUT I don't want the Personal.XLSB to show in the list, further, once the user picks the file name (from the list of open files) I want to make that file the active file. I have spent three hours with many variations INSTR (using numbers or just text) and even text comparison, OR USING "PERSONAL.xlsb" in the "instr" below, but I cant get it to work at all. Ever have one of this days?????
Any insights anyone can give?
CODE FOLLOWS:
' Populate the open file name list box excluding Personal.xlsb
Dim wbOpen As Workbook
Dim wbopenText As String
ListBoxOpenFiles.Clear
For Each wbOpen In Workbooks
wbopenText = wbOpen.Name
If InStr(1, wbopenText, "Per") = 0 Then
ListBoxOpenFiles.AddItem wbOpen.Name ' add the name to the list
MsgBox wbOpen.Name & "Added to list"
End If
If InStr(1, wbopenText, "Per") = 1 Then ' If "Personal" is NOT found skip
End If 'Loop again
Next
' next step - make the existing file the active workbook
'still to do