I am trying to write a macro to automatically create html documents from a mail merge document which is reading data from an Access database. I have succesfully written the following code:
Sub Macro2()
'
ChangeFileOpenDirectory _
"\\Your-axy8yb6izy\jon kelly\My Documents\Alpine Winters Website\public_html\resorts\france\les_gets\"
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdFirstRecord
For i = 0 To 5
ActiveDocument.SaveAs FileName:="chalet" & i & ".html", FileFormat:=wdFormatText, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, Encoding:=1252, InsertLineBreaks:=False, AllowSubstitutions:=False _
, LineEnding:=wdCRLF
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord
Next
End Sub
However I still have two problems:
1. I would like to count the number of records in the intitial Access Query so that I can set the For....Next loop to this number.
2. I would like to set the filename to one of the fields in the query.
Can anybody help.
Jon Kelly
Sub Macro2()
'
ChangeFileOpenDirectory _
"\\Your-axy8yb6izy\jon kelly\My Documents\Alpine Winters Website\public_html\resorts\france\les_gets\"
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdFirstRecord
For i = 0 To 5
ActiveDocument.SaveAs FileName:="chalet" & i & ".html", FileFormat:=wdFormatText, _
LockComments:=False, Password:="", AddToRecentFiles:=True, WritePassword _
:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, SaveAsAOCELetter:= _
False, Encoding:=1252, InsertLineBreaks:=False, AllowSubstitutions:=False _
, LineEnding:=wdCRLF
ActiveDocument.MailMerge.DataSource.ActiveRecord = wdNextRecord
Next
End Sub
However I still have two problems:
1. I would like to count the number of records in the intitial Access Query so that I can set the For....Next loop to this number.
2. I would like to set the filename to one of the fields in the query.
Can anybody help.
Jon Kelly