Read our blogs, tips and tutorials
Try our exercises or test your skills
Watch our tutorial videos or shorts
Take a self-paced course
Read our recent newsletters
License our courseware
Book expert consultancy
Buy our publications
Get help in using our site
545 attributed reviews in the last 3 years
Refreshingly small course sizes
Outstandingly good courseware
Whizzy online classrooms
Wise Owl trainers only (no freelancers)
Almost no cancellations
We have genuine integrity
We invoice after training
Review 30+ years of Wise Owl
View our top 100 clients
Search our website
We also send out useful tips in a monthly email newsletter ...
We have 12 VBA - working with files videos listed below.
Posted by Andrew Gould on 03 March 2014
Posted by Andrew Gould on 10 March 2014
Posted by Andrew Gould on 11 March 2014
Posted by Andrew Gould on 26 November 2015
Posted by Andrew Gould on 03 April 2021
Posted by Andrew Gould on 03 April 2021
Posted by Andrew Gould on 03 April 2021
Posted by Andrew Gould on 03 April 2021
Posted by Andrew Gould on 06 April 2021
Posted by Andrew Gould on 07 April 2021
Posted by Andrew Gould on 18 August 2021
Posted by Andrew Gould on 03 October 2021
You might also like to consider booking a place on one of our online or classroom VBA courses, where you could meet the owls behind the videos!
From: | duggie |
When: | 24 Aug 23 at 16:25 |
I have File Dialog box, where the user can choose where to save their file.
Option Explicit
Sub ChooseFileLocationToSave()
Dim FileSelector As FileDialog
Set FileSelector = Application.FileDialog(fileDialogType:=msoFileDialogSaveAs)
With FileSelector
.FilterIndex = 1
.InitialFileName = ThisWorkbook.Path & "\"
.Title = "Please Type A Filename"
Dim FileSelected As Boolean
FileSelected = .Show
End With
If FileSelected <> False Then
Application.DisplayAlerts = False
ThisWorkbook.SaveAs Filename:=FileSelector.SelectedItems(1), _
FileFormat:=51
Application.DisplayAlerts = True
End If
Set FileSelector = Nothing
End Sub
I also have a Workbook_BeforeSave Event:
Option Explicit
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
Dim MyArray() As Variant
MyArray() = Sheet1.Cells(1, 1).CurrentRegion.Value
End Sub
For some reason, when I try to save the workbook, the contents of the array is not read, which causes the program to crash, with a Run Time error 13. Type Mismatch message.
Is this a bug or have I missed something?
Thanks
From: | Andrew G |
When: | 25 Aug 23 at 08:31 |
Weird! It seems to be an issue with CurrentRegion used in an event procedure.
Try this instead:
Dim MyArray() As Variant
MyArray() = Sheet1.Range("A1", Range("A1").End(xlDown).End(xlToRight))
Hope it helps!
Kingsmoor House
Railway Street
GLOSSOP
SK13 2AA
Landmark Offices
99 Bishopsgate
LONDON
EC2M 3XD
Holiday Inn
25 Aytoun Street
MANCHESTER
M1 3AE
© Wise Owl Business Solutions Ltd 2024. All Rights Reserved.