June 2006

Selection to CSV

Obviously you could adapter it to do what ever type of text file you like (well, and Excel can handle)

VBA:
  1. Option Explicit
  2.  
  3. Private Const BIF_RETURNONLYFSDIRS As Long = &H1
  4. Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2
  5. Private Const BIF_RETURNFSANCESTORS As Long = &H8
  6. Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000
  7. Private Const BIF_BROWSEFORPRINTER As Long = &H2000
  8. Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000
  9. Private Const MAX_PATH As Long = 260
  10.  
  11. Type BrowseInfo
  12. hOwner As Long
  13. pidlRoot As Long
  14. pszDisplayName As String
  15. lpszINSTRUCTIONS As String
  16. ulFlags As Long
  17. lpfn As Long
  18. lParam As Long
  19. iImage As Long
  20. End Type
  21.  
  22. Type SHFILEOPSTRUCT
  23. hwnd As Long
  24. wFunc As Long
  25. pFrom As String
  26. pTo As String
  27. fFlags As Integer
  28. fAnyOperationsAborted As Boolean
  29. hNameMappings As Long
  30. lpszProgressTitle As String
  31. End Type
  32.  
  33. Declare Function SHGetPathFromIDListA Lib "shell32.dll" ( _
  34. ByVal pidl As Long, _
  35. ByVal pszBuffer As String) As Long
  36.  
  37. Declare Function SHBrowseForFolderA Lib "shell32.dll" ( _
  38. lpBrowseInfo As BrowseInfo) As Long
  39.  
  40. Public Sub Save_To_Where()
  41.  
  42. Dim sFolderName As String
  43. Dim sFileName As String
  44. Dim sdefult As String
  45.  
  46. sdefult = "M.I.E Export to CSV - " & Application.UserName & " - " _
  47. & Round((Timer), 0)
  48.  
  49. sFolderName = BrowseFolder("Save Text File Where?")
  50. If sFolderName = "" Then
  51. Exit Sub
  52. Else
  53. sFileName = InputBox("Entre the file name you would like to use", "File Name", sdefult)
  54. If Len(sFileName) = 0 Then
  55. Exit Sub
  56. End If
  57. End If
  58.  
  59. SaveAsText sFolderName, sFileName
  60.  
  61. End Sub
  62.  
  63. '''Fuction to get directory
  64. Function BrowseFolder(Optional Caption As String = "") As String
  65.  
  66. Dim BrowseInfo As BrowseInfo
  67. Dim FolderName As String
  68. Dim ID As Long
  69. Dim Res As Long
  70.  
  71. With BrowseInfo
  72. .hOwner = 0
  73. .pidlRoot = 0
  74. .pszDisplayName = String$(MAX_PATH, vbNullChar)
  75. .lpszINSTRUCTIONS = Caption
  76. .ulFlags = BIF_RETURNONLYFSDIRS
  77. .lpfn = 0
  78. End With
  79.  
  80. FolderName = String$(MAX_PATH, vbNullChar)
  81.  
  82. ID = SHBrowseForFolderA(BrowseInfo)
  83.  
  84. If ID Then
  85. Res = SHGetPathFromIDListA(ID, FolderName)
  86. If Res Then
  87. BrowseFolder = Left$(FolderName, InStr(FolderName, _
  88. vbNullChar) - 1)
  89. End If
  90. End If
  91.  
  92. End Function
  93.  
  94. Public Sub SaveAsText(sFolder As String, sName As String)
  95.  
  96. On Error GoTo ErrorHandler
  97.  
  98. Application.ScreenUpdating = False
  99.  
  100. Selection.Copy
  101.  
  102. Workbooks.Add
  103. ActiveWorkbook.Sheets(1).Paste
  104. ActiveWorkbook.SaveAs Filename:=sFolder & "\" & sName & ".csv", FileFormat:=xlCSVMSDOS
  105. Application.DisplayAlerts = False
  106. ActiveWorkbook.Close
  107. Application.DisplayAlerts = True
  108. Application.ScreenUpdating = True
  109.  
  110. Exit Sub
  111.  
  112. '''Error handerling
  113. ErrorHandler:
  114. If Err.Number = 1003 Then
  115. MsgBox "Error, did you use <,>,?,[,], :, | or *" _
  116. & vbNewLine & "Make sure the folder exists" _
  117. & vbNewLine & "Make sure the ile/path name is not onger than 218 letters" _
  118. & vbNewLine & "Make sure the folder is not read only", _
  119. vbOKOnly, "Error Exporting Text File"
  120. Exit Sub
  121. Else
  122. MsgBox "An unexpected error occured, export aborted", vbOKOnly, "Error Exporting Text File"
  123. Exit Sub
  124. End If
  125.  
  126. End Sub

Excel 2007, what’s the story

Well it's been out for a while, but I've not seen a lot about it in the Excel community. So what do you think to the new version?

0470044039.01._SCMZZZZZZZ_.jpg

I have uninstalled it on my mechanics; it was way too much of a pain. I couldn't open files by default in an earlier version and that was a massive problem, because I couldn't really do any work with 2007.

Downers about 2007

Ribbons.
Ok hard to use to start off with, fair play, that's a learning curve but I found that I really missed toolbars I could call up and float in the work space. The Toolbox toolbar for example. I tend to have fixed toolbars with really common buttons, then call up specific toolbars when I need them. I found I was forever having to change the tab to get top the tool set I wanted - I might as well use menus.

VBA.
If you've done anything with toolbars or menus your in trouble! Also much other code seems to be a bit hit or miss, which is hard to believe.

Interface colour.
Is it just me or does anyone else hate, hate, hate that bloody washed out blue colour MS insist on using? It was the same in 2003. In the 2007 beta blues the default and I can change that to a "Visa" grey (Vista grey is in fact black and all but unusable), More importantly the blue makes it really difficult to make out some of the tool buttons in the VBE. (I wonder if you could use the toolbars from the VBE, which are the same as ever, in the new Excel interface?)

The "Office Button"
That big round button in the top right"¦ Didn't really win me over, the popup looks naff, it feels like a bit of a catch all where MS can stick stuff that doesn't really go anywhere else.

The Zoom Bar
Anyone with a scroll mouse will have no need for this, not that it's that much of a feature anyway.

The Good Things.

Charts look much nicer (although I'm lead to belie they are hard to customise).

Formatting is much improved.

Colours seem better.

so what's your take on the new version?????

Making Spreadsheets Correct

Don't worry I'm still alive! Despite only making one post last month I have in fact been doing quite a lot of programming. I hope to have something reasonably interesting to post soon.
In the mean time, if you care to drag yourselves away from that Beat for a few moments, this might be worth a read!

Making Spread Sheets Correct