Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-04-2020, 05:21 AM
Kain Kain is offline Code to NOT RUN an (autosave) macro within a macro Windows 10 Code to NOT RUN an (autosave) macro within a macro Office 2019
Novice
Code to NOT RUN an (autosave) macro within a macro
 
Join Date: Aug 2020
Posts: 2
Kain is on a distinguished road
Default Code to NOT RUN an (autosave) macro within a macro

Is there a way to have a macro NOT running??

I made an AUTOCLOSE ()macro to that saves document, then saves it again in another location (Finalcopy.doc)


However, I also have a macro [SPARECOPY ()]that copies all text to a file, then saves that file (workingcopy.doc) to a specific location, then closes workingcopy.doc and goes back to the original file.
(a less optimal ‘SaveCopyAS, so to speak)


Thus, when the file workingcopy.doc is closed, I automatically make a Finalcopy.doc.

So to optimize the macro, I’d try inserting something like DoNotCall AUTOCLOSE () or Dontrun.Application in my SPARECOPY () macro, but well, since those commands don’t exist I have to find an other way.



Any ideas?
Reply With Quote
  #2  
Old 08-04-2020, 05:36 AM
Guessed's Avatar
Guessed Guessed is offline Code to NOT RUN an (autosave) macro within a macro Windows 10 Code to NOT RUN an (autosave) macro within a macro Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 3,932
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

Have a look at the bottom of this page. Does that work for you?
RoseTech - Word VBA - Sample Code - Auto Macros | Word Auto Macro examples | Word Auto Macro VBA Tips | Word Auto Macro suggestions
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
  #3  
Old 08-04-2020, 06:32 AM
Kain Kain is offline Code to NOT RUN an (autosave) macro within a macro Windows 10 Code to NOT RUN an (autosave) macro within a macro Office 2019
Novice
Code to NOT RUN an (autosave) macro within a macro
 
Join Date: Aug 2020
Posts: 2
Kain is on a distinguished road
Default

This is EXACTLY what I was looking for !!

Thank you very much.


My macros are:

Sub AutoClose()

'
' When closing document, saves with original name + location,
' then to D:\reservekopie\finalcopy+date+time
'
'

Dim strPath, strFile As String

strPath = "D:\reservekopie" 'set path
strFile = "finalcopy_" 'set filename


ActiveDocument.Save
ActiveDocument.SaveAs FileName:=strPath & strFile & _
Format((Date), " ddMMMMyyyy ") & Format((Time), "HHumm")
ActiveWindow.Close
Selection.HomeKey Unit:=wdLine
WordBasic.DisableAutoMacros 0 'Enables Auto Macros

End Sub


Sub Sparecopy()
'
' makes copy of content, saves to D:\reservekopie\workingcopy+date+time
'
'
WordBasic.DisableAutoMacros 1 'Disables Auto Macros

Dim strPath, strFile As String
Selection.WholeStory
Selection.Copy
Documents.Add Template:="Normal", NewTemplate:=False, DocumentType:=0
Selection.PasteAndFormat (wdFormatOriginalFormatting)

strPath = "D:\reservekopie" 'set path
strFile = "workingcopy" 'set filename

ActiveDocument.SaveAs FileName:=strPath & strFile & _
Format((Date), " ddMMMMyyyy ") & Format((Time), "HHumm") & Format(Order, "_00#")
ActiveWindow.Close
Selection.HomeKey Unit:=wdLine

WordBasic.DisableAutoMacros 0 'Enables Auto Macros

End Sub
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Create a macro to autosave a file every 5 minutes and up-rev the filename SPJSPENCER Word VBA 3 12-12-2019 11:55 AM
Code to NOT RUN an (autosave) macro within a macro VBA Macro code help get4hari Excel Programming 8 09-26-2015 10:33 PM
VBA Code to create a Macro Shazz Outlook 0 03-10-2015 09:52 AM
Code to NOT RUN an (autosave) macro within a macro Looking Again for Another Code/Macro rsrasc Word VBA 5 11-16-2014 05:47 AM
Need Macro code for Outlook gbaker Outlook 0 04-11-2013 10:29 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:00 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft