Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Is there a way to tell this macro to open in cell A6 and to preserve the
formatting of the worksheet? Sub Macro1() ' ' Macro1 Macro ' Macro recorded 3/13/2009 ' ' Workbooks.OpenText Filename:= _ "\\admis.adm\kcdfs\kcusers\A829917\My Documents\Seg Positions.txt", Origin:= _ xlWindows, StartRow:=6, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), _ Array(10, 1), Array(16, 1), Array(41, 1)), TrailingMinusNumbers:=True End Sub |
#2
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
This is opening a text file. There is no formatting associated with text
files--they're plain text. But you can specify how each field should be treated (general, text, date, skipped) in that fieldinfo parm. If you wanted, you could insert 5 empty lines at the top of the text file or have your macro insert 5 rows at the top of the worksheet. You could add a line to your code after the file is opened: activesheet.rows(1).resize(5).insert And you could apply any formatting you want (number/font/fill) after the data is imported. Do it manually and record a macro. Then add this recorded code to your existing macro and you should be close to set. chrisnsmith wrote: Is there a way to tell this macro to open in cell A6 and to preserve the formatting of the worksheet? Sub Macro1() ' ' Macro1 Macro ' Macro recorded 3/13/2009 ' ' Workbooks.OpenText Filename:= _ "\\admis.adm\kcdfs\kcusers\A829917\My Documents\Seg Positions.txt", Origin:= _ xlWindows, StartRow:=6, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), _ Array(10, 1), Array(16, 1), Array(41, 1)), TrailingMinusNumbers:=True End Sub -- Dave Peterson |
#3
![]()
Posted to microsoft.public.excel.misc
|
|||
|
|||
![]()
Hi,
You should be able to accomplish this without a macro by using the text import feature. With this feature you can specify a starting cell to place the data and also preserve cell formatting. The properties that you set can be saved with the file and used as a sort of template for opening (importing) the text file. You may want to start here; http://www.j-walk.com/ss/excel/usertips/tip030.htm If you're using Excel 2007 try he http://office.microsoft.com/en-us/ex...997251033.aspx Best wishes. Dave "chrisnsmith" wrote in message ... Is there a way to tell this macro to open in cell A6 and to preserve the formatting of the worksheet? Sub Macro1() ' ' Macro1 Macro ' Macro recorded 3/13/2009 ' ' Workbooks.OpenText Filename:= _ "\\admis.adm\kcdfs\kcusers\A829917\My Documents\Seg Positions.txt", Origin:= _ xlWindows, StartRow:=6, DataType:=xlFixedWidth, FieldInfo:=Array(Array(0, 1), _ Array(10, 1), Array(16, 1), Array(41, 1)), TrailingMinusNumbers:=True End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
excel 2003 saved file will not open without a blank workbook open | Excel Discussion (Misc queries) | |||
In Excel - Use Windows Explorer instead of File Open to open file | Excel Discussion (Misc queries) | |||
Open email windows can't open, excel shreadsheet file .xls ? | Excel Discussion (Misc queries) | |||
file open via IE hyperlink causes already open files to shrink and tile | Setting up and Configuration of Excel | |||
How do I stop Excel from closing the open file each time I open a. | Setting up and Configuration of Excel |