View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.programming
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default How Do I Use List Box for VBA Script that Converts Excel Files to Any FIle Type?


"socrtwo" wrote in message
s.com...

Bob Phillips wrote:
That is probably because you have loaded the listbox with the constant
names, but it is the constant value that is used by the VBA statement.

Create a 2 column list, one with the names, one with the value, like so,

xlAddin 18
xlCSV 6
etc.

and set the listbox to reference this list, then in the code use

ActiveWorkbook.SaveAs _
Filename:=Left(myfiles(i), Len(myfiles(i)) - 4) & "_" _
& wks.Name, _

FileFormat:=lbxExcelFileClass.List(lbxExcelFileCla ss.Listindex,1)


Bob, thanks for replying. I see I may be asking for a value when it's
really a string I'm looking for. I looked up the table of the class
values he

http://msdn.microsoft.com/library/de...HV01049962.asp
and replaced my table with that one.
I put in you code to replace mine and still got the error.



Shouldn't have if you did it correctly.


I looked up the error and it seems that since I started my code with
"Options Explicit", I needed to Dim the variable. So my question is,
can I keep my list which explains what each xl[file type] in the second
column, if I just Dim lbxExcelFileClass as a string?
Also, how do I make sure the form gets displayed?



What variable? lbxExccelClassFile is the name of your listb os I assume, so
it is already defined.



If I put back my table the way it was originally and Dim
lbxExcelFileClass as a string and make
FileFormat:=lbxExcelFileClass.String. I get another compile error:
"invalid qualifier.
Any ideas?



Don't Dim lbxExcleClassFile, it is a listbox. I just ran another test and

ActiveWorkbook.SaveAs "C:\GetRidof",
FileFormat:=lbxExcelFileClass.List(lbxExcelFileCla ss.ListIndex, 1)

worked fine.