probleme de fermeture...

StefBel

New Member
Joined
Jun 21, 2016
Messages
6
Bonjour,

J'ai programmé un fichier de facon a ce que je sauvegarde 2 copies, 1 avec VBA et 1 sans VBA.

Au début les 2 copies sauvegardais sans vba, mais en déplacant "CreateBackupIncre" au début les 2 copies se sauvegarde de la bonne facon.


Depuis que j'ai ajouté le code ci-bas, lorsque je fais oui pour sauvegarde les 2 copies se font mais mon dossier reste ouvert.

si je fais non le dossier ferme.

J'ai un sub workbook_before close ajouter mais lorsque je sauvegarde on dirait qu'il ne va pas dans ce sub.




Sub SaveWithoutMacros() 'Save a copy of the active workbook without macros

CreateBackupIncre

Dim vFilename As Variant
Dim wbActiveBook As Workbook



Application.DisplayAlerts = False

On Error GoTo CodeError



ActiveWorkbook.SaveCopyAs "G:\WEBXXXX\WEBENTRN\entrainement READ ONLY WEB2.xls"

Set wbActiveBook = Workbooks.Open("G:\WEBXXXX\WEBENTRN\entrainement READ ONLY WEB2.xls")


Set VBComps = wbActiveBook.VBProject.VBComponents
For Each VBComp In VBComps
Select Case VBComp.Type
Case vbext_ct_StdModule, vbext_ct_MSForm, _
vbext_ct_ClassModule
VBComps.Remove VBComp
Case Else
With VBComp.CodeModule
.DeleteLines 1, .CountOfLines
End With
End Select
Next VBComp

wbActiveBook.Save


SetAttr "G:\WEBXXXX\WEBENTRN\entrainement READ ONLY WEB2.xls", vbReadOnly





MsgBox "Une copie a été envoyé sur le site WEB XXXX"


Application.DisplayAlerts = True


Merci et bonne journée !!!

StefBel
 

Excel Facts

When did Power Query debut in Excel?
Although it was an add-in in Excel 2010 & Excel 2013, Power Query became a part of Excel in 2016, in Data, Get & Transform Data.
Bonjour StefBel
Vous pourriez avoir un problème avec l'ordre des fichiers sauvegardés
J'essaie d'enregistrer le fichier d'abord avec VBA
Après avoir enregistré le fichier sans VBA
Après la fermeture du fichier
Lors de la sauvegarde le fichier sans VBA, elle perd le code ne peut pas ouvrir ou exécuter plus VBA, pas le code qui est en cours d'exécution
Sergio
 
Upvote 0

Forum statistics

Threads
1,215,022
Messages
6,122,726
Members
449,093
Latest member
Mnur

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top