I save an Access report as a RTF document and would like from within Access to convert it to a Word document. I set up the code in Access as follows but it does not save the file. Can anyone help ? strF1Month = "FileName" Set docSource = wdApp.Documents.Open(strF1Month) docSource.SaveAs FileName:=strF1Month, FileFormat:=wdFormatDocument
Various possible problems 1. The filename will probably actually be FileName.rtf rather than just FileName 2. The filename that you save the document in Word format should be FileName.doc. So you may need to do some processing of the strF1Month string to get the extension right. 3. I would recommend you include the full pathname in strF1Month rather than just the filename. That way you are not dependent on Word's current folder happening to be where the file is located. 4. If you have not set a reference to the Word object model in Tools References, and have instead set a late-bound reference to wdApp using GetObject or CreateObject, then your code will not know the value of the constant wdFormatDocument. Put its value in instead, which is 0. -- Regards Jonathan West - Word MVP www.intelligentdocuments.co.uk Please reply to the newsgroup Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org "rmcompute" wrote in message news:990115D2-3AB8-4C24-9E1A-901D69AE32F3@microsoft.com... >I save an Access report as a RTF document and would like from within Access > to convert it to a Word document. I set up the code in Access as follows > but > it does not save the file. Can anyone help ? > > strF1Month = "FileName" > > Set docSource = wdApp.Documents.Open(strF1Month) > docSource.SaveAs FileName:=strF1Month, FileFormat:=wdFormatDocument >
Thank you. "Jonathan West" wrote: > Various possible problems > > 1. The filename will probably actually be FileName.rtf rather than just > FileName > > 2. The filename that you save the document in Word format should be > FileName.doc. So you may need to do some processing of the strF1Month string > to get the extension right. > > 3. I would recommend you include the full pathname in strF1Month rather than > just the filename. That way you are not dependent on Word's current folder > happening to be where the file is located. > > 4. If you have not set a reference to the Word object model in Tools > References, and have instead set a late-bound reference to wdApp using > GetObject or CreateObject, then your code will not know the value of the > constant wdFormatDocument. Put its value in instead, which is 0. > > -- > Regards > Jonathan West - Word MVP > www.intelligentdocuments.co.uk > Please reply to the newsgroup > Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org > > > "rmcompute" wrote in message > news:990115D2-3AB8-4C24-9E1A-901D69AE32F3@microsoft.com... > >I save an Access report as a RTF document and would like from within Access > > to convert it to a Word document. I set up the code in Access as follows > > but > > it does not save the file. Can anyone help ? > > > > strF1Month = "FileName" > > > > Set docSource = wdApp.Documents.Open(strF1Month) > > docSource.SaveAs FileName:=strF1Month, FileFormat:=wdFormatDocument > > > >