This category will hold articles regarding developement in Excel VBA. It will serve as a wiki and an Excel VBA Framework for myself.
Some development tasks reoccur for every customer. Since I am a lazy bum it will be nice to have a central source where I can reuse source code from.
Below function displays a file picker dialog and returns the picked file path as String.
' @Author - Alexander Bolte
' @ChangeDate - 2014-10-09
' @Description - Displaying a Windows explorer standard file picker dialog to user and returning picked file path as String.
' @Returns - A String holding a full file path. If user aborted file picker dialog the returned String is empty("").
Public Function getSingleFilePath() As String
Dim myFileDialog As FileDialog
Dim filePath As String
' Search for file.
Set myFileDialog = Application.FileDialog(msoFileDialogFilePicker)
myFileDialog.InitialView = msoFileDialogViewDetails
' Prompt dialog to user.
If myFileDialog.Show = -1 Then
filePath = myFileDialog.SelectedItems.Item(1)
getSingleFilePath = filePath
- Hits: 3126
Saving an Excel workbook is a rather simple task. However you have to regard many things in IO operations, which can go wrong.
Therefore it is always good to add some extra exception handling for IO operations that are likely to fail.
Hence, although saving a workbook requires only one line of code I use below method for saving workbooks.
- Hits: 3009
In one of my projects I had to read all worksheet names from several Excel files.
Here is the code for getting all worksheet names from a closed or already opened Excel file.
Referenced Functions can be found below.
Getting all sheet names from a workbook
Getting an opened Excel workbook
- Hits: 3080
Page 8 of 10