98.7% Of all customers recommend us, we're so confident about our results we publish all reviews and stats
View Live Stats View ReviewsForum home » Delegate support and help forum » Microsoft Excel VBA Training and help » Saving changes made by VBA
Saving changes made by VBA
Resolved · Medium Priority · Version 2007
Ian has attended:
Excel VBA Intro Intermediate course
Saving changes made by VBA
I have used the following code to opne a file and protect and share the file however the changes are lost when file closes. any suggestions
Sub endofrepmessage()
With Application
.EnableEvents = False
.ScreenUpdating = False
.DisplayAlerts = False
End With
Sheets("Menu").Select
Range("F34:G35").Interior.ColorIndex = 50
Range("F34:G35") = "Update Completed" & " " & Now()
'
Workbooks.Open FileName:= _
"S:\Healthcare\JOINT HEALTHCARE INFO\KPIs\AZ Cost KPI\AZ CC Archive.xlsm"
Sheets("AZ Archive Complete").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
Sheets("AZ Archive New").Select
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
If Not ActiveWorkbook.MultiUserEditing Then
ActiveWorkbook.SaveAs ActiveWorkbook.Name, accessmode:=xlShared
End If
ActiveWorkbook.Close SaveChanges:=True
MsgBox "Now Shared"
End Sub
RE: saving changes made by VBA
Hi Ian
Thanks for getting in touch. When you're using the SaveAs method in Excel 2007, you need to specify the FileFormat to make sure it is saved as an XLSM (macro enabled workbook).
You'll need a line like this:
ActiveWorkbook.SaveAs ActiveWorkbook.Name, accessmode:=xlShared, fileformat:=52
There's more detail on this from the excellent Ron DeBruin:
http://blogs.office.com/2009/07/07/use-the-vba-saveas-method-in-excel-2007/
You might want to try commenting out the "DisplayAlerts = False" line while you're testing, to make sure it trips the save command.
Kind regards
Gary Fenn
Microsoft Office Specialist Trainer
Tel: 0207 987 3777
Best STL - https://www.stl-training.co.uk
98%+ recommend us
London's leader with UK wide delivery in Microsoft Office training and management training to global brands, FTSE 100, SME's and the public sector
Fri 21 Mar 2014: Automatically marked as resolved.
Training information:
Welcome. Please choose your application (eg. Excel) and then post your question. Our Microsoft Qualified trainers will then respond within 24 hours (working days). Frequently Asked Questions
Any suggestions, questions or comments? Please post in the Improve the forum thread. |
Excel tip:Showing all menu itemsIf you go into a pull down menu you usally find that you get a selection of items(this is the default) or sometimes everything. If you only get a selectiopn you have to go to the double arrows at the bottom of the menu and click it to get all of the hidden items. |