![]() |
|
#1
|
|||
|
|||
![]()
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?
|
#2
|
|||
|
|||
![]()
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 |
#3
|
|||
|
|||
![]() 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. |
![]() |
|
![]() |
||||
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 |