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)

Option Explicit

Private Const BIF_RETURNONLYFSDIRS As Long = &H1
Private Const BIF_DONTGOBELOWDOMAIN As Long = &H2
Private Const BIF_RETURNFSANCESTORS As Long = &H8
Private Const BIF_BROWSEFORCOMPUTER As Long = &H1000
Private Const BIF_BROWSEFORPRINTER As Long = &H2000
Private Const BIF_BROWSEINCLUDEFILES As Long = &H4000
Private Const MAX_PATH As Long = 260

Type BrowseInfo
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszINSTRUCTIONS As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Type SHFILEOPSTRUCT
hwnd As Long
wFunc As Long
pFrom As String
pTo As String
fFlags As Integer
fAnyOperationsAborted As Boolean
hNameMappings As Long
lpszProgressTitle As String
End Type

Declare Function SHGetPathFromIDListA Lib "shell32.dll" ( _
ByVal pidl As Long, _
ByVal pszBuffer As String) As Long

Declare Function SHBrowseForFolderA Lib "shell32.dll" ( _
lpBrowseInfo As BrowseInfo) As Long

Public Sub Save_To_Where()

Dim sFolderName As String
Dim sFileName As String
Dim sdefult As String

sdefult = "M.I.E Export to CSV - " & Application.UserName & " - " _
& Round((Timer), 0)

sFolderName = BrowseFolder("Save Text File Where?")
If sFolderName = "" Then
Exit Sub
Else
sFileName = InputBox("Entre the file name you would like to use", "File Name", sdefult)
If Len(sFileName) = 0 Then
Exit Sub
End If
End If

SaveAsText sFolderName, sFileName

End Sub

'''Fuction to get directory
Function BrowseFolder(Optional Caption As String = "") As String

Dim BrowseInfo As BrowseInfo
Dim FolderName As String
Dim ID As Long
Dim Res As Long

With BrowseInfo
.hOwner = 0
.pidlRoot = 0
.pszDisplayName = String$(MAX_PATH, vbNullChar)
.lpszINSTRUCTIONS = Caption
.ulFlags = BIF_RETURNONLYFSDIRS
.lpfn = 0
End With

FolderName = String$(MAX_PATH, vbNullChar)

ID = SHBrowseForFolderA(BrowseInfo)

If ID Then
Res = SHGetPathFromIDListA(ID, FolderName)
If Res Then
BrowseFolder = Left$(FolderName, InStr(FolderName, _
vbNullChar) - 1)
End If
End If

End Function

Public Sub SaveAsText(sFolder As String, sName As String)

On Error GoTo ErrorHandler

Application.ScreenUpdating = False

Selection.Copy

Workbooks.Add
ActiveWorkbook.Sheets(1).Paste
ActiveWorkbook.SaveAs Filename:=sFolder & "\" & sName & ".csv", FileFormat:=xlCSVMSDOS
Application.DisplayAlerts = False
ActiveWorkbook.Close
Application.DisplayAlerts = True
Application.ScreenUpdating = True

Exit Sub

'''Error handerling
ErrorHandler:
If Err.Number = 1003 Then
MsgBox "Error, did you use <,>,?,[,], :, | or *" _
& vbNewLine & "Make sure the folder exists" _
& vbNewLine & "Make sure the ile/path name is not onger than 218 letters" _
& vbNewLine & "Make sure the folder is not read only", _
vbOKOnly, "Error Exporting Text File"
Exit Sub
Else
MsgBox "An unexpected error occured, export aborted", vbOKOnly, "Error Exporting Text File"
Exit Sub
End If

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