Here's a challenging one:
I have obtained the script below from a previous forum post. The object is to automatically save a mail merged word file in a spefified directory. The procedure works fine if I enter an absolute dir path. HOWEVER, I am using a 'variable' directory path. The operative directory name had been automatically created from a prior procedure (PEOPLE-"LAST_NAME) dependent on the active record. I have adapted the script as I thought best to include the reference to that 'variable' sub-folder but without success (phew, I hope this makes sense). Any idea what that 'variable' reference should look like or what is required to achieve this?
The error I get is: "OLE automation error. This is not a valid file name." (Just a reminder again that the procedure works fine with a predefined file path - i.e. the valid file name error is not neccesarily a clue).
app = ole.GetObject("","word.application")
app.visible = .t. 'make sure Word is visible
app.activate()
Dim shared ws_mydoc as C
'ws_id below is a unique document number that I sorted out earlier in unseen code
ws_mydoc="C:\Contacts\Correspondence" + chr(92) + alltrim(PEOPLE-"LAST_NAME) + chr(92) + dmy(date())+ ".doc"
app.ActiveDocument.SaveAs(ws_mydoc)
app.ActiveDocument.close()
Thanks
Hendrik
I have obtained the script below from a previous forum post. The object is to automatically save a mail merged word file in a spefified directory. The procedure works fine if I enter an absolute dir path. HOWEVER, I am using a 'variable' directory path. The operative directory name had been automatically created from a prior procedure (PEOPLE-"LAST_NAME) dependent on the active record. I have adapted the script as I thought best to include the reference to that 'variable' sub-folder but without success (phew, I hope this makes sense). Any idea what that 'variable' reference should look like or what is required to achieve this?
The error I get is: "OLE automation error. This is not a valid file name." (Just a reminder again that the procedure works fine with a predefined file path - i.e. the valid file name error is not neccesarily a clue).
app = ole.GetObject("","word.application")
app.visible = .t. 'make sure Word is visible
app.activate()
Dim shared ws_mydoc as C
'ws_id below is a unique document number that I sorted out earlier in unseen code
ws_mydoc="C:\Contacts\Correspondence" + chr(92) + alltrim(PEOPLE-"LAST_NAME) + chr(92) + dmy(date())+ ".doc"
app.ActiveDocument.SaveAs(ws_mydoc)
app.ActiveDocument.close()
Thanks
Hendrik
Comment