![]() |
#1
|
|||
|
|||
![]() Is there a way to program a merged word document to save as a filename? I have tried to do this through access coding and I am 99.99% effective, but once in a while, the File Save As box pops open prompting the user to save the file. Thanks. |
#2
|
|||
|
|||
![]()
I routinely do it, but the merged document is (1) merged as a part of a macro, (2) attached to a separate template following the merge (through that macro), and then that template has an intercept for the SaveAs and Save commands. (It also finishes by attaching the merged document to the normal template.)
|
#3
|
|||
|
|||
![]()
My Access application opens up the new word document based on the template as a new document and then merges it. The merge works fine. How do I intercept the file save as then.... I can't believe someone else does this! Would it be code I put in the template?
|
#4
|
|||
|
|||
![]()
This is my code from Access:
Dim myfilename As String myfilename = ReportDir & LabNumber & "_" & ItemNumber & "_" & CATEGORY & ".doc" Dim mypassword As String mypassword = DecryptPIN(DLookup("PIN_NUMBER", "ANALYST", "FULL_NAME='" & ana_txt & "'")) 'save to temp directory wordapp.ActiveDocument.SaveAs filename:=myfilename, WritePassword:=mypassword wordapp.ActiveDocument.Close |
#5
|
||||
|
||||
![]()
See 'Send Mailmerge Output to Individual Files' and 'Split Merged Output to Separate Documents' in the Sticky thread (https://www.msofficeforums.com/mail-...ps-tricks.html) at the top of the mailmerge forum (I've moved this discussion there).
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#6
|
|||
|
|||
![]() Quote:
Because my code is scattered in different templates it would be a major effort to rewrite it for what you are doing. Here is code putting the current date as a tag at the end of the suggested name when saving a new document. I have this in a template. It is sometimes a nuisance, but most files I create I like to put the date as a tag. Code:
Public Sub SaveWithDate(Optional strName As String) ' Run as substitute for FileSave to add date to default document names ' Put in a global template as public macro ' Call this from other templates ' If strName is supplied, it is used as the base name, otherwise the base comes from the Title Property On Error Resume Next If Len(ActiveDocument.Path) > 0 Then ' The document has already been saved at least once. ' Just save and exit the macro. ActiveDocument.Save Exit Sub End If ' If strName = "" Then strName = strName & ActiveDocument.BuiltInDocumentProperties("Title").Value 'get name in title Dim dlgSave As Dialog Set dlgSave = Dialogs(wdDialogFileSaveAs) strName = strName & " " & Format((Year(Now() + 1) Mod 100), "20##") & "-" & _ Format((Month(Now() + 1) Mod 100), "0#") & "-" & _ Format((Day(Now()) Mod 100), "0#") ActiveDocument.BuiltInDocumentProperties("Title").Value = strName ActiveDocument.BuiltInDocumentProperties("Company").Value = "Kenyon Law Office" With dlgSave .Name = strName .Show End With End Sub Sub FileSave() Application.Run "SaveWithDate" End Sub Sub FileSaveAs() Application.Run "SaveWithDate" End Sub Again, if I just wanted it to automatically save the file with the chosen name, I would use .Execute instead of .Show. |
#7
|
||||
|
||||
![]()
Hi Charles,
Question: What are you trying to achieve with this: Code:
Format((Year(Now() + 1) Mod 100), "20##") & "-" & _ Format((Month(Now() + 1) Mod 100), "0#") & "-" & _ Format((Day(Now()) Mod 100), "0#") Code:
Format(Date, "YYYY-MM-DD")
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
RG87 | Word VBA | 1 | 05-21-2014 05:39 AM |
How do I save a Word file with a macro for distribution? | leemoreau | Word VBA | 3 | 10-04-2013 08:06 AM |
![]() |
mickeyw3340 | Mail Merge | 2 | 12-18-2012 11:30 AM |
![]() |
wayne | Word | 8 | 08-15-2011 03:56 PM |
![]() |
jabberwocky12 | Word VBA | 2 | 10-22-2010 12:23 PM |