Pedro Janssen
pedro at plex.nl
Mon May 24 14:32:50 CDT 2004
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$???). 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)? Thanks Pedro Janssen For Each prop In ActiveDocument.CustomDocumentProperties If prop.Name = "BezoekRapportID" Then strFileNamePart = prop.Value Exit For End If Next ----- Original Message ----- From: "Stuart McLachlan" <stuart at lexacorp.com.pg> To: "Access Developers discussion and problemsolving" <accessd at databaseadvisors.com> Sent: Monday, May 24, 2004 12:35 AM Subject: Re: [AccessD] auto save in word > On 23 May 2004 at 23:03, Pedro Janssen wrote: > > > Hello Group, > > > > > > After merging data from access with use of properties in word, i use > > the code below to save a word document in a certain directory with the > > name; Bezoekrapport("BezoekrapportID").doc, by clicking a button. When > > the documentname in the directory already excist i would have the name > > changed to Bezoekrapport("BezoekrapportID")_1.doc or > > Bezoekrapport("BezoekrapportID")_2.doc etc, etc. Can this been done? > > > > > Just check for the existence of a file with the name and suffix and > increment it if necessary in a loop until you find a unique one. > > Dim flgSaved as Boolean > Dim strSuffix as String > flgSaved = False > strSuffix = "" > > Do > strFilename = > Dir$("W:\WerkbrievenOpslag\Bezoekrapport\Bezoekrapport" _ > & strFileNamePart & "_" & strSuffix & ".doc" > If Dir$(strFilename) > " " Then ' File exists > strSuffix = str$(val(strSuffix)+1) ' use a larger suffix > Else > flg Saved = True > ActiveDocument.SaveAs FileName:=strFilename > flgSaved = True > End If > Loop Until flgSaved > > > > -- > 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 > >