Changing a file extension
Steve,
Given below is the macro I have. It looks for *.xls files in a folder
(Path) and then retrieves D1 to D20 values, places them in column A.
Likewise, E1 to E20 values are placed in column B.
I need to fetch those values from *.log files. I am not sure if the
macro would work, unless and until I change the *.log to *.xls
Kevin
Path = Dir(MyPath & "*.xls")
Set sh = Sheets("Sheet1")
Fnum = 0
Do While Path < ""
Fnum = Fnum + 1
ReDim Preserve MyFiles(1 To Fnum)
MyFiles(Fnum) = Path
Path = Dir()
Loop
If Fnum 0 Then
For Fnum = LBound(MyFiles) To UBound(MyFiles)
rnum = LastRow(sh)
Set destrange = sh.Cells(rnum + 1, "A")
GetData MyPath & MyFiles(Fnum), "Sheet1", "D1:D20",
destrange, False, False
Set destrange = sh.Cells(rnum + 1, "B")
GetData MyPath & MyFiles(Fnum), "Sheet1", "E1:E20",
destrange, False, False
Next
End If
On Apr 14, 4:51 pm, "Steve Yandl" wrote:
Kevin,
You should probably share your macro as it is now and explain what you want
to accomplish. If you have file names listed in a workbook or a text file
and they include the full path, it is certainly possible to alter the
extensions of the referenced files but it is also possible to get Excel to
regard them as the text files they are and act accordingly. Depending on
your goal and the scenario, the second option is probably far safer.
Steve Yandl
wrote in message
...
Macropod,
My macro uses
Set sh = Sheets("Sheet1")
So, its not working with *.log file. Now, I have to change the *.log
file to *.xls file.. I have no other option, I guess!
Kevin
On Apr 14, 4:38 pm, wrote:
Hi Macropod,
When I manually rename that *.log file to *.xls and open that excel
file, I find the excel file in good shape. I understand that this is
not possible in all cases but in this particular case, it works.
The *.log file has data in 4 column, which when opened in a excel
file, is arranged in A, B, C and D columns respectively. The macro I
have references the column A and B of the excel file. Since, I have a
*.log file, I am not sure how my macro would associate the columns in
the *.log file as A and B. I guess this is possible only if the log
file is changed into an excel file.
This being the case, per your reply, my macro should be able to read
the values from *.log file? I am going to give this a shot.
Cheers
Kevin
On Apr 14, 4:26 pm, "macropod" wrote:
Hi Kevin,
The file extension needn't affect your macro's ability to read the
*.txt and *.log files' contents. In any event, changing the
extension doesn't turn the files into Excel files and could cause other
problems. Plus, you'll still need to understand those files'
structure and code accordingly.
Cheers
--
macropod
[MVP - Microsoft Word]
-------------------------
wrote in
...
Hello group,
I have a macro to pull the values in row A and B of a workbook, to
another workbook. I have some values in the files that have *.txt and
*.log extension.
Is there any macro to change the extension of the file (*.txt and
*.log) to *.xls? Please let know.
Thanks,
Kevin
|