Avoid "Save" dialog after running AutoOpen macro

I wrote AutoOpen macro that shows or hides the Document Map depending of a 
document properties. The macro works properly, but now, when I close any 
document, I get a prompt "Do you want to save the changes..." even if I have 
changed nothing in the document.

I tried to put "ActiveDocument.Saved = True" as the last command of the 
AutoOpen macro, but it doesn't help.

So far I've found a workaround: I put "ActiveDocument.Save" as the last 
command of the AutoOpen macro. However, the workaround causes updating a 
document's modified time every time when the document is open.

Can anyone suggest a better solution?
0
Utf
5/6/2010 3:15:01 PM
word.vba.general 1023 articles. 1 followers. Follow

4 Replies
1021 Views

Similar Articles

[PageSpeed] 24

Hi LeonidG
Looks like your code changes something else to. As far as I know,
showing the Document Map is not a change to the document.
Could there be anyting else happening in the code that triggers the
change, or do you have fields in the documents that are updated on
opening?

Greetings,
Rinze Smit
Revalidatie Friesland
0
Rinze
5/7/2010 5:33:21 PM
Hi, Rinze

Here's the code of my macro:

Sub AutoOpen()
    On Error GoTo ErrHandler
    If ActiveDocument.BuiltInDocumentProperties("Keywords").Value = 
"SHOWMAP" Then
        ActiveWindow.DocumentMap = True
        ActiveWindow.View.ShowHeading 1
    Else
        ActiveWindow.ActivePane.Close
    End If
    ActiveDocument.Save
    GoTo EndOfMacro

ErrHandler:
    If Err.Number = 5867 Then
        Err.Clear
    Else
        MsgBox Err.Description & " " & Err.Number
    End If
EndOfMacro:
End Sub

I've made some tests and found that my dealing with the document properties 
triggers the change. So I see two alternative ways:
- find another way to recognize a "mapped" document;
- clean the flag of changes after it has been set.

I've forgot to mention, my version of the Word is 2007

0
Utf
5/10/2010 4:31:01 PM
Another way to recognize a "mapped" document would be to set a document 
variable in the document to True using

ActiveDocument.Variables("Mapped") = "ShowMap"

Then for your autoopen macro use:

'Sub AutoOpen()
    On Error GoTo ErrHandler
    If ActiveDocument.Variables("Mapped").Value = "ShowMap" Then
        ActiveWindow.DocumentMap = True
        ActiveWindow.View.ShowHeading 1
    End If
    ActiveDocument.Save
    GoTo EndOfMacro

ErrHandler:
    If Err.Number = 5825 Then
        ActiveDocument.Close
        GoTo EndOfMacro
    Else
        MsgBox Err.Description & " " & Err.Number
    End If
EndOfMacro:
End Sub




-- 
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"LeonidG" <LeonidG@discussions.microsoft.com> wrote in message 
news:F049EAAF-61FD-4F34-A259-A85258D68E84@microsoft.com...
> Hi, Rinze
>
> Here's the code of my macro:
>
> Sub AutoOpen()
>    On Error GoTo ErrHandler
>    If ActiveDocument.BuiltInDocumentProperties("Keywords").Value =
> "SHOWMAP" Then
>        ActiveWindow.DocumentMap = True
>        ActiveWindow.View.ShowHeading 1
>    Else
>        ActiveWindow.ActivePane.Close
>    End If
>    ActiveDocument.Save
>    GoTo EndOfMacro
>
> ErrHandler:
>    If Err.Number = 5867 Then
>        Err.Clear
>    Else
>        MsgBox Err.Description & " " & Err.Number
>    End If
> EndOfMacro:
> End Sub
>
> I've made some tests and found that my dealing with the document 
> properties
> triggers the change. So I see two alternative ways:
> - find another way to recognize a "mapped" document;
> - clean the flag of changes after it has been set.
>
> I've forgot to mention, my version of the Word is 2007
> 
0
Doug
5/10/2010 9:46:17 PM
Doug, many thanks. With a document variable it works much better. Here's my 
final code:

Sub AutoOpen()
    On Error GoTo ErrHandler
    ActiveWindow.DocumentMap = True
    If ActiveDocument.Variables("Mapped").Value = "ShowMap" Then
        ActiveWindow.View.ShowHeading 1
    End If
    GoTo EndOfMacro

ErrHandler:
    If Err.Number = 5825 Then
        Err.Clear
        ActiveWindow.ActivePane.Close
    Else
        MsgBox Err.Description & " " & Err.Number
    End If
EndOfMacro:
End Sub

0
Utf
5/11/2010 5:58:01 AM
Reply:

Similar Artilces:

File.Save does not really save the current (or complete) status of the excel workbook (XL2000)
I am facing a funny (???) phenomenon when I (or others) save a large (approx. 8MB) Excel 2000 workbook. Especially when I make changes to a dialog, then save the workbook and open it again, these changes are not (or only partially ???) effective... But also simple changes to one or more of the Worksheets (approx. 20 large sheets) will not be saved consistently. Any help ? - Gerhard I've never seen excel do this with any size workbook. Are you sure you're opening the file that you just saved? Maybe your saved version is in a different folder. Try putting this formula in a worshee...

Auto save in excel 2000 keeps reverting to 10 minutes
I keep trying to change the time between auto-saves to 30 minutes, but every time I reopen excel 2000 it is back to 10 minutes. How do I get this change to be permanent? Thanks. Create a workbook with this code in a general module: Option Explicit Sub auto_open() On Error Resume Next Workbooks("autosave.xla").Excel4IntlMacroSheets("Loc Table") _ .Range("ud01n.Frequency1").Value = 10 If Err.Number <> 0 Then MsgBox "Timer not changed!" Err.Clear End If On Error GoTo 0 'ThisWorkbook.Close SaveChanges:=False ...

How do I bring up a file that I saved as an Excel file?
I am taking classes and have to do work on Excel and was wondering why when I save them I can't retrieve them? I can see the file names but am not able to retrieve them I am inexperienced on Office. Hi open excel, choose file & open, locate your files, click on the one you want to open and press the Open button. however, if the files that you want to open are on a floppy disk then it is a VERY good idea to copy them onto your hard drive before opening them. This is best achieved using windows explorer. to do this: right mouse click on the start button choose explore ensure the flo...

sent messages are not saved in the sent items folder
Hi! With no special reson, and with everything configured the way it should be my outlook 2002 just stopped saving the sent messages in my sent items folder any idea? Thanks in advance, Nir. There is a setting for that. You might want to check it just to be sure. Under Tools, Options, Preferences, Email Options, there is a box that says "Save copies of messages in Sent Items folder". Is that checked? >-----Original Message----- >Hi! >With no special reson, and with everything configured the way it should be >my outlook 2002 just stopped saving the sent messages...

How can we get rid of the "Save" pop up box at the end of application?
Whenever the user closes the excel sheet, it pops up an "save?" pop up. Is there a way to get rid of this? --- Message posted from http://www.ExcelForum.com/ It should only ask that question if it thinks you have altered data on the sheet. The only way around this is to write a macro and place a button on the sheet that would close the sheet with one click without asking to save it first. You may be able to use an auto_Run macro to tell the sheet that you have already saved it and don' ask again. If you know how to do macros, the magic code is. sub CloseSheet() acti...

trial version Outlook 2007 -Power Point Edit & Save
Just downloaded the trial. In Power Point, why can't I edit and save the doc? I can only view and print. Help! AndreaG wrote: > Just downloaded the trial. And what was the URL from where you downloaded? According to your Subject header, you downloaded the trial version of just Outlook 2007. I didn't realize that Microsoft had a separate trial of Outlook. They do have a trial version of /Office/ 2007. > In Power Point, why can't I edit and save the doc? > I can only view and print. Did you enter the 25-character *trial* product key after download...

clipboard doesn't always save contents
Is there a setting that lets Excel save clipboard contents until something overwrites it? I'm on Excel 2003 and ever since I can remember when you highlight a cell or a group of cells and then hit CTRL+C to copy the cell(s) get marqueed. When you move to a different cell they can be copied. But if you save the sheet or do various other things like deleting a different sheet in the workbook the clipboard is erased so that you can no longer copy them into anything else. If I were to copy some cells to the clipboard and then close the workbook, I would not be able to paste that info in...

Finding a text and save it's address
Hi all, In a specificspred sheet list,I am look for a specific text.after finding the text,I need to save it's position . my hinge is to use combination of .find ()& .address....If you know the answer,please let me know Thank you very much! I have a VBA procedure at http://www.cpearson.com/Excel/Findall.aspx that will find all occurrences of a value in a specified range of cells. As its result, it returns a Range object that references each cell in which the value was found. Using that function (posted at the end of this message), you can do something like: Sub AAA() Dim RangeT...

Outlook not prompting where to save attachments.
When trying to save attachment files, outlook is no longer prompting me where to save the files. Files are automatically saved to some default location. How do I change this setting? I have browsed through all menus and it is not obvious where to change. thanks How are you trying to save? opening the attachment and then saving, or rt clicking the attachment, then saving? "AnaC" <AnaC@discussions.microsoft.com> wrote in message news:95BF9BD6-EF31-4D96-AD81-EF420C5A80AE@microsoft.com... > When trying to save attachment files, outlook is no longer prompting ...

Avoid "Save" dialog after running AutoOpen macro
I wrote AutoOpen macro that shows or hides the Document Map depending of a document properties. The macro works properly, but now, when I close any document, I get a prompt "Do you want to save the changes..." even if I have changed nothing in the document. I tried to put "ActiveDocument.Saved = True" as the last command of the AutoOpen macro, but it doesn't help. So far I've found a workaround: I put "ActiveDocument.Save" as the last command of the AutoOpen macro. However, the workaround causes updating a document's modified time eve...

undo saved excel file (very urgent)
Hi everybody, I have saved an excel file accidentally and I have to take the file back before saving.How can I do?Please help. If I dont it will take too much time to reprepare the file.Thank you Hi The file is overwritten. You have to find one of your backup CDs. HTH. best wishes Harald "onur ekinci" <onur.ekinci@arcelik-lg.com> skrev i melding news:1c5e01c49a4c$27c68490$a501280a@phx.gbl... > Hi everybody, > I have saved an excel file accidentally and I have to take > the file back before saving.How can I do?Please help. If I > dont it will take too much tim...

Can't save file in network or hard disk
Receive new xp last week and running excel 2000. The file has 12 tabs and lots of data linking between tabs. Sporadically, I cannot save the file back on the network, cannot save under another name, and cannot even save on the c:drive. The message is "xxx.xls cannot be accessed. The file may be read only, or you may be trying to access a read-only location. Or, the server the document is stored on may not be responding". The network is not down and I am not disconnected from the network. I do not encounter this problem with the old nt. Other files have less tabs and less c...

Save data entered into a form
Hi, I am new to access 2003 and have been training myself. I have created a form based on 2 tables. I have both bound and unbound boxes within the form. I have a search command button which allows the user to quickly search through the records to find the correct record and allows data entry into each text box but when i save the form, all the data entered into the form is lost and the form opens at the first record again. I have tried to apply a filter which works, but I still cannot save the data entered into the text box fields. I am sure it is a simple expression i need t...

Publisher 2000
Very recently I have noticed that when saving a modest sized document whether manually or when the "time to save" reminder comes up, it is taking about one minute to save and in that time the system allows no other access. I wonder if the installation is corrupt? Publisher creates temp files, deleting these may help. Look in the Windows folder for a temp folder. A general disk clean-up may be in store too. -- Mary Sauer MS MVP http://office.microsoft.com/ http://www.mvps.org/msauer/ news://msnews.microsoft.com "Andrew" <anonymous@discussions.microsoft.com> wro...

How to call a filename as per information in a cell when using `save as`
I wish to open a templete and input information then when I click on the save button it saves it and calls the file the same name as information in a particular cell. Is this Poss. Hi put the following code in your workbook module Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As _ Boolean) dim fname application.enableevents=false fname=me.worksheets("sheet1").range("A1").value fname=fname&".xls" me.savesas fname application.enableevents=true Cancel = True End Sub -- Regards Frank Kabel Frankfurt, Germany Dave wrote: > I wish t...

picture in a vcard -- won't hold even when saved
i'm not sure what happens. i have it in my contact, it's listed under my signature and saved in the vcard place. but something must be filtering out the picture. i'm ready to go over the perverbial ms bridge. help!! A vCard is not the same as a contact. A vCard is stored as vcf-file as Plain Text (you can open it in NotePad) and cannot hold attachments A Contact is stored as msg-file which is not Plain Text but can hold attachments (picture) A vCard is a standard that many contact management programs and PDA's can handle -- Robert Sparnaaij [MVP-Outlook] www.howto-out...

Retrieve/Recover data following my stupidity when asked to save changes
Can i retrieve data entered into a spreadsheet (after several hours of work) when I accidentally clicked "no" when asked if I wanted to save changes. I attempted to system restore, however, that failed to return my previous entries. Hi Philly! Afraid not! System Restore specifically does not touch files that you create. Jan Karel Pieterse's AutoSafe might be an Addin that will be better at preventing this problem. http://www.bmsltd.co.uk/MVP/Default.htm Here's the blurb: The standard Autosave (note the spelling) utility that ships with Excel just saves workbooks at a s...

how do i save worksheet as a jpeg file
i need to save excel worksheet as a jpeg file Select the range on the worksheet and SHIFT + Edit>Copy Picture. Open MS Paint or your favorite graphics program and paste the picture. Save As Type..........jpg. Gord Dibben MS Excel MVP On Thu, 8 Mar 2007 04:29:21 -0800, jaxrob <jaxrob@discussions.microsoft.com> wrote: >i need to save excel worksheet as a jpeg file Thanks Gord that took care of main problem, but it only copied first 7 rows of sheet not the 15 i had selected. how do i select the whole sheet to copy as picture? "Gord Dibben" wrote: > Select th...

Records not being saved
Hi In MSCRM3.0 we have been updating contact address details. In certain instances the records are being saved and at other times it has not been saved. No error message appears. Please can someone assist with this strange behaviour? Thanks Clinton ...

Excel asking for save with no changes #3
Yes, "=NOW()". I'll try removing it. Thanks -- tommy2 ----------------------------------------------------------------------- tommy20's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=281 View this thread: http://www.excelforum.com/showthread.php?threadid=27781 ...

Office 2008 causes fatal conflict ("black screen of death") when trying to save
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Hello all, I'm in some rather dire need of assistance - any help you could give me regarding this topic would so much appreciated! The problem is this: We are a college music department trying to run a suite of iMacs over a Windows network. The iMacs are locked to their maximum level, so only administrators can perform updates (regular users can't even, for example, save a new "Normal" Word document template!). More often than not, whenever we try to save projects (in all applications but most noticabl...

Save last row to use in another set of code
I run this bit of code to find the address of the the last cell in column K. Sub test() Dim x As Range Worksheets("NCSA_ISS_ITEM_BOM").Activate Set x = Cells(Rows.Count, "K").End(xlDown) MsgBox x.Address End Sub I would like to save the resulting row address as a variable to run as part of another set of code. How would I go about doing this? If you move your Dim statement outside of the subroutine (that is, move it into the General/Declarations section of the code module you are in), then any code within that code module will be ab...

cannot save logo to e mail signature
trying to save a logo to outlook signature, when clicking advance edit i get a message that 'the next program in incompatible with outlook', i an m able to continue and create the signature with logo in Word but when saved the logo does not appear in the preview box. I have saved some print characters to the signature but not the logo. What version of Outlook are you using? -- -Ben- Ben M. Schorr, MVP Roland Schorr & Tower http://www.rolandschorr.com http://www.officeforlawyers.com/outlook.html Author: The Lawyer's Guide to Microsoft Outlook 2007: http://...

trying to save a presentation (pps) It doesn't work
I've tried to save a presentation (pps) for automatic running, but I can't. Saving it as pps, it opens as ppt. Any suggestions? I'm using power point 2003 HOW are you opening? pps files only open in show mode if you open from windows explorer (ie double click) File > Open will always open in edit mode. If this is not the problem get back. -- john ATSIGN PPTAlchemy.co.uk Free PPT Hints, Tips and Tutorials http://www.pptalchemy.co.uk/powerpoint_hints_and_tips_tutorials.html "Paloma - Lanzarote" wrote: > I've tried to save a...

cannot save a change to a file
Each time I add or change an esisting file in word 2003 I recieve a message asking me to send an error report but no change to the file is made. ...