Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
Si Si is offline
external usenet poster
 
Posts: 9
Default *.csv to *.xls



To All the more Intelligent People out there than I. (Thanks for the Input &
Time)

Here's what I'm trying to do.
Build a Macro that opens a specific folder and looks for all *.csv and
allows the individual to select a certain *.csv file and then Import it to
the *.xls Workbook that is running the Macro.
The *.csv file that is being imported already has the information in cells
IE: It looks like a *.xls Have been messing around with this for far to long,
tried building a seperate Macro just to convert the *.csv into a *.xls So
that I can then CopyPaste the Information into the Workbook that I'm trying
to get it into. However it just Saves my Original workbook instead of the
*.csv
Have posted before under "open command" (this is my second post ever)
When I use record (which I do most of the time, and then modify) and the
*.csv file is specified it works fine.
Please Help I know this can be done.

Sub Convert()
'
' Convert Macro
' Macro recorded 29/06/2006 by Si
'

'
ChDir "C:\TEMP"
Application.GetOpenFilename ("text files, *.csv")
ActiveWorkbook.SaveAs Filename:="C:\TEMP\Import This.xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub
Sub Import()
'
' Import Macro
' Macro recorded 29/06/2006 by Si
'

'
Workbooks.Open Filename:="C:\TEMP\Import This.xls"
Range("A1:AH19").Select
Selection.Copy
Windows("Excel Workbook.xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
End Sub

One Macro would be better but if I could get Individuals to Select *.csv and
the Paste into *.xls that would save on my Workbook size?

Cheers for any Help


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default *.csv to *.xls


To import csv file:

Sheets.Add Type:="C:\FileName.csv"

To Select multiple files:

InputFileArray = Application.GetOpenFilename("CSV Files (*.csv)
*.csv", 1, "Select File(s)", , True)

If Not IsArray(InputFileArray) Then Exit Sub

For i = LBound(InputFileArray) To UBound(InputFileArray)

InsertCSV (InputFileArray(i))

Next

--
Kaa
-----------------------------------------------------------------------
Kaak's Profile: http://www.excelforum.com/member.php...nfo&userid=751
View this thread: http://www.excelforum.com/showthread.php?threadid=55685

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default *.csv to *.xls


There's some .csv to .xls stuff here as well....

http://www.excelforum.com/showthread.php?t=556592

Hope this helps!

SudokuKin

--
SudokuKin
-----------------------------------------------------------------------
SudokuKing's Profile: http://www.excelforum.com/member.php...fo&userid=3586
View this thread: http://www.excelforum.com/showthread.php?threadid=55685

  #4   Report Post  
Posted to microsoft.public.excel.programming
Si Si is offline
external usenet poster
 
Posts: 9
Default *.csv to *.xls

Took some time but Played with it for quite some time and then I got it!
I then slapped myself for being so dumb.
But heres what I was looking for:
"Workbooks.Open Filename:=Application.GetOpenFilename("text files, *.csv")"
Thanks to those that tried to Help.
Guess I should have stated I was a Newbie and that what I was looking for
was the simplest answer.


"Si" wrote:



To All the more Intelligent People out there than I. (Thanks for the Input &
Time)

Here's what I'm trying to do.
Build a Macro that opens a specific folder and looks for all *.csv and
allows the individual to select a certain *.csv file and then Import it to
the *.xls Workbook that is running the Macro.
The *.csv file that is being imported already has the information in cells
IE: It looks like a *.xls Have been messing around with this for far to long,
tried building a seperate Macro just to convert the *.csv into a *.xls So
that I can then CopyPaste the Information into the Workbook that I'm trying
to get it into. However it just Saves my Original workbook instead of the
*.csv
Have posted before under "open command" (this is my second post ever)
When I use record (which I do most of the time, and then modify) and the
*.csv file is specified it works fine.
Please Help I know this can be done.

Sub Convert()
'
' Convert Macro
' Macro recorded 29/06/2006 by Si
'

'
ChDir "C:\TEMP"
Application.GetOpenFilename ("text files, *.csv")
ActiveWorkbook.SaveAs Filename:="C:\TEMP\Import This.xls",
FileFormat:=xlNormal, _
Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
CreateBackup:=False
End Sub
Sub Import()
'
' Import Macro
' Macro recorded 29/06/2006 by Si
'

'
Workbooks.Open Filename:="C:\TEMP\Import This.xls"
Range("A1:AH19").Select
Selection.Copy
Windows("Excel Workbook.xls").Activate
Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone,
SkipBlanks _
:=False, Transpose:=False
Range("A1").Select
End Sub

One Macro would be better but if I could get Individuals to Select *.csv and
the Paste into *.xls that would save on my Workbook size?

Cheers for any Help


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 08:24 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"