Microsoft Office Tutorials and References
In Depth Information
Figure 17-3. A fixed-width text file opened in Excel
4-125-160
The code:
Workbooks.OpenText _
FileName:="d:\excel\temp.txt", _
Origin:=xlMSDOS, _
StartRow:=1, _
DataType:=xlFixedWidth, _
FieldInfo:=Array(Array(0, 2), _
Array(1, 9), Array(2, 2), Array(5, 9), _
Array(6, 2))
produces the worksheet in Figure 17-3 . (Note how we included arrays to skip the hyphens.)
Figure 17-3. A fixed-width text file opened in Excel
Finally, it is important to observe that the text file is opened in Excel, but not converted to an
Excel workbook file. To do so, we can invoke the SaveAs method, as in:
Application.ActiveSheet.SaveAs _
FileName:="d:\excel\temp.xls", _
FileFormat:=xlWorkbookNormal
17.2 The Workbook Object
A Workbook object represents an open Excel workbook. As we have discussed, Workbook
objects are stored in a Workbooks collection.
The Workbook object has a total of 103 properties and methods, as shown in Table 17-1 .
ble 17-1. Members of the Workboo k object
_CodeName
FullName
RefreshAll
_PrintOut<v9>
FullNameURLEncoded<v10>
RejectAllChanges
_Protect<v10>
HasMailer
ReloadAs<v9>
_ReadOnlyRecommended<v10> HasPassword
RemovePersonalInformation<v10>
_SaveAs<v10>
HasRoutingSlip
RemoveUser
AcceptAllChanges
HighlightChangesOnScreen
Reply
AcceptLabelsInFormulas
HighlightChangesOptions
ReplyAll
Activate
HTMLProject<v9>
ReplyWithChanges<v10>
ActiveChart
IsAddin
ResetColors
ActiveSheet
IsInplace
RevisionNumber
AddToFavorites
KeepChangeHistory
Route
 
 
 
 
Search JabSto ::




Custom Search