jaguar5554
asked on
MS Word 2010 (32-bit) macro does not work in MS Word 2016 (64-bit)
I found the below macro/code in a Google search and I inserted into an MS Word 2010 (32-bit) document. The macro works great in MS Word 2010 (specifically, takes what the user enters into a form field named "Title:" and saves that text along with "SOP" and the current date in a specific folder on a network share). Unfortunately, the macro does not run in MS Word 2016 (64-bit). Can anyone assist in adjusting the macro/code to also run in Word 2016? Any assistance is greatly appreciated. Thanks much in advance- apc
Sub FileSaveAs()
Dim MyDocTitle As String
MyDocTitle = Format(Date, "mm dd yyyy")
Selection.HomeKey Unit:=wdStory
Selection.Find.ClearFormatting
With Selection.Find
.Text = "Title:"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
If Selection.Find.Found Then
Selection.MoveRight Unit:=wdCharacter, Count:=1
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.MoveLeft Unit:=wdCharacter, Count:=2, Extend:=wdExtend
If Len(Selection.Text) > 1 Then
MyDocTitle = Selection.Text + " SOP " + MyDocTitle
End If
End If
With Dialogs(wdDialogFileSummaryInfo)
.Title = MyDocTitle
.Execute
End With
Dialogs(wdDialogFileSaveAs).Show
End Sub
Sub AutoNew()
'
Dim strNewPath As String
strNewPath = "s:\policies and procedures\" ' Set save location
ChangeFileOpenDirectory strNewPath
'ActiveDocument.Save
End Sub
ASKER
My apologies for not responding earlier but did not see your comment. To answer yours, no error message! The expected result is on File SaveAs, the macro should insert the filename into the dialog box, pointing to the specific file location. Instead, the SaveAs dialog adds the first couple of words it finds in the document and points to the default file save location (MS Word as-built functionality). Basically, the macro does not run in Windows 10/Office 2016 (64-bit). Note: The macro works as expected in Window 7/Office 2010 (32-bit). Any help or insight you can provide is greatly appreciated! Thank you-
Hi,
Just noting that you've commented out:
but that doesn't seem to be what you refer to in your second post?
Is it the:
that doesn't execute?
If so, what do you get if you enter that exact command in the immediate window? Does the dialogue come up (in the main word window)?
If you just want to save the document then use (changing the file path and file name):
Or 'ActiveDocument' or an object variable that is the document you want to save - as appropriate.
The stuff you've populated into the File Summary Info dialogue (title for example) is not the same as the filename - they can and often will be different.
Alan.
Just noting that you've commented out:
ActiveDocument.Save
but that doesn't seem to be what you refer to in your second post?
Is it the:
Dialogs(wdDialogFileSaveAs).Show
that doesn't execute?
If so, what do you get if you enter that exact command in the immediate window? Does the dialogue come up (in the main word window)?
If you just want to save the document then use (changing the file path and file name):
ThisDocument.SaveAs "C:\Temp\ZZ_Filename"
Or 'ActiveDocument' or an object variable that is the document you want to save - as appropriate.
The stuff you've populated into the File Summary Info dialogue (title for example) is not the same as the filename - they can and often will be different.
Alan.
ASKER
Again my apologies for not getting back to this post. I used to get an email notifications for responses but no longer. I will review your comment's and try any suggestions you provided and get back to this post. Thanks much!!!
No problem - let me know.
You can also reset notificiations from your EE account settings (if you want).
Alan.
You can also reset notificiations from your EE account settings (if you want).
Alan.
ASKER
My apologies but I do not believe the above provided a solution and, since 2019, we've migrated to O365 and Sharepoint and the problem persists -- yet differently. As I am not proficient in VBA, I'm afraid I do not know where to apply the suggested change. I will do a little more testing and research, and, in the meantime, this question can remain open for anyone else to respond -- specifically, how to adjust the above code so that on when saving, the save as dialog box auto opens to a specific location with the specific filename (as outlined in the code above). Thank you-
ASKER
Absolutely. Thank you!
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
There are two macros - which one does not work?