Pedro Janssen
pedro at plex.nl
Tue May 25 15:20:10 CDT 2004
Hello Stuart and others, i tried to put my code (docproperties) and your code (suffix) together When BezoekrapportID value =1, and saving true code i get as filename Bezoekrapport1_.doc in the right directory. Saving it again nothing happens. Then adjusting the code after Do, changing If Filename .... to If strFilename then saving by code, word crashes. Could you take a look at it again. Thanks Pedro Janssen Sub Bezoekrapport() Dim flgSaved As Boolean Dim strSuffix As String flgSaved = False strSuffix = "" For Each prop In ActiveDocument.CustomDocumentProperties If prop.Name = "BezoekrapportID" Then strFileNamePart = prop.Value Exit For End If Next strFileName = "C:\Werkbrieven Opslag\Bezoekrapport\Bezoekrapport" & strFileNamePart & "_" & strSuffix & ".doc" Do If FileName > " " Then strSuffix = (Val(strSuffix) + 1) Else flgSaved = True ActiveDocument.SaveAs FileName:=strFileName flgSaved = True End If Loop Until flgSaved End Sub ----- Original Message ----- From: "Stuart McLachlan" <stuart at lexacorp.com.pg> To: "Access Developers discussion and problemsolving" <accessd at databaseadvisors.com> Sent: Tuesday, May 25, 2004 3:02 AM Subject: Re: [AccessD] auto save in word > On 24 May 2004 at 21:32, Pedro Janssen wrote: > > > Hello Stuart, > > > > thanks for your help. When a file exists it makes suffixes like _ 1, _ 2 > > etc., but these are saved in My Documents (Dir$???). > > Yes, they would be the way I wrote that aircode :-( > Try: > Document.SaveAs FileName:= > "W:\WerkbrievenOpslag\Bezoekrapport\Bezoekrapport" _ > & strFileNamePart & "_" & strSuffix & ".doc" > > >Can you give me a hand > > on how to use the doc properties in your code (i placed them in the code, > > but with no result)? > > > Not sure what you are asking for here > > > > For Each prop In ActiveDocument.CustomDocumentProperties > > If prop.Name = "BezoekRapportID" Then > > strFileNamePart = prop.Value > > Exit For > > End If > > Next > > This is looking for a custom property called "BezoekRapportID" and > setting strFileNamePart to the value of that property. Have you set > an appropriate Name/Value in the the documents properties under the > "Custom" tab? > > > -- > Lexacorp Ltd > http://www.lexacorp.com.pg > Information Technology Consultancy, Software Development,System > Support. > > > > -- > _______________________________________________ > AccessD mailing list > AccessD at databaseadvisors.com > http://databaseadvisors.com/mailman/listinfo/accessd > Website: http://www.databaseadvisors.com > >