Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d759699

Browse files
committed
Disable events and don't save the Excel file while closing
1 parent 60cd9cd commit d759699

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

‎README.md‎

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# Excel - Export code to flat files
2+
23
> Export every code objects (classes, forms, modules and worksheet code) to flat fliles, in a batch mode
34
45
## Table of Contents
@@ -11,21 +12,21 @@
1112

1213
## Description
1314

14-
This VB script will export all code objects (classes, forms, modules and worksheet macro) from an Excel file (can be .xlsm or .xlam) to flat files on your disk.
15+
This VB script will export all code objects (classes, forms, modules and worksheet macro) from an Excel file (can be `.xlsm` or `.xlam`) to flat files on your disk.
1516

16-
This way, you'll get a quick backup of your code and you'll be able to synchronize your code on a versionning platform like GitHub.
17+
This way, you'll get a quick backup of your code and you'll be able to synchronize your code on a versioning platform like GitHub.
1718

1819
The script will start Excel (hidden way), open the specified file, process every code object and export them, one by one, in a `\src\your_file.xlsm` folder.
1920

20-
The `src` folder will be automatically created if needed and you'll find a subfolder having the same name of your file (so you can have more than one exported file in the same src folder).
21+
The `src` folder will be automatically created if needed and you'll find a sub-folder having the same name of your file (so you can have more than one exported file in the same src folder).
2122

2223
## Install
2324

24-
Just get a copy of the .vbs script, perhaps the .cmd too (for your easiness) and save them in the same folder of your Excel application (containing the code you want to export).
25+
Just get a copy of the `.vbs` script, perhaps the `.cmd` too (for your easiness) and save them in the same folder of your Excel application (containing the code you want to export).
2526

2627
## Usage
2728

28-
Just edit the .cmd file and you'll see how it works: you just need to run the .vbs with one parameter, the name of your file.
29+
Just edit the `.cmd` file and you'll see how it works: you just need to run the `.vbs` with one parameter, the name of your file.
2930

3031
![demo](image/demo.png)
3132

‎excel_export_code.vbs‎

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,9 @@ Class clsMSExcel
288288
End If
289289

290290
oApplication.DisplayAlerts = False
291+
oApplication.EnableEvents = False
292+
oApplication.ScreenUpdating = False
293+
291294
Set wb = oApplication.Workbooks.Open(sFileName, bUpdateLinks, bReadOnly)
292295

293296
If Not (wb is Nothing) Then
@@ -344,9 +347,15 @@ Class clsMSExcel
344347
End if ' If Not (wb is Nothing) Then
345348

346349
On error Resume Next
347-
wb.Close
348-
Set wb = Nothing
349-
On error GOto 0
350+
' Don't save changes
351+
wb.Close False
352+
Set wb = Nothing
353+
On error GoTo 0
354+
355+
' Restore settings
356+
oApplication.DisplayAlerts = True
357+
oApplication.EnableEvents = True
358+
oApplication.ScreenUpdating = True
350359

351360
End Sub
352361

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /