Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I have the below portion of code in a program that collects a bunch of text
files and imports them into multiple worksheets in one Excel Workbook. Dim InputFiles As Variant Dim MyFirstWorkbook As Object InputFiles = Application _ .GetOpenFilename("Text Files (*.txt), *.txt", , "*** PLEASE SELECT INPUT FILES ***", , True) If IsArray(InputFiles) < False Then Lower = LBound(InputFiles) Upper = UBound(InputFiles) Set MyFirstWorkbook = GetObject(InputFiles(1)) The code line "Set MyFirstWorkbook = GetObject(InputFiles(1))" produces the error "File name or class name not found during Automation operation." I realize that I must have to add some sort of class argument to the GetObject function but do not know what. When I try the function with GetObject(InputFiles(1), "Excel.Workbook") I get the error "ActiveXcomponent can't create object." All the input files will be text (.txt) files. What I need to know is how to adjust the GetObjectFunction class argument (or something else) to get this to work properly. Can anyone help??? Further on in my code after I have opened a text (.txt) file in Excel using the Workbooks.OpenText method. There I can successfully use the GetObject function. I guess once the file is opened in Excel you are able to do this. The code I am using here is: Dim MyWorkbook As Workbook Set MyWorkbook = GetObject(InputFiles(InputFileNo)) However, the text file is already opened as an Excel file when I do this. That is not the case when I am trying to set the MyFIRSTWorkbook object. Any help would be greatly appreciated. Thanks, Bill Horton |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
GetObject function | Excel Programming | |||
(Disable macro's while) using the GetObject | Excel Programming | |||
GetObject | Excel Programming | |||
GetObject-question | Excel Programming | |||
Is there a better option than Getobject to access a .xls? | Excel Programming |