Thanks a lot for that TheColonial.
I have got further on and have actually managed to get it to compile, but when it comes to the SaveAs bit it errors. here is my code, it may not be the tidiest but when I get to grips with it I will tidy up.
Code:
VARIANT saveaway;
VARIANT varempty;
varempty.vt = VT_ERROR;
varempty.scode = DISP_E_PARAMNOTFOUND;
saveaway.vt = VT_BSTR;
_bstr_t myBString(path);
BSTR parampass = (BSTR)myBString;
saveaway.pbstrVal = ¶mpass;
oDoc.SaveAs(
&saveaway, //FileName
&varempty, //FileFormat
&varempty, //LockComments
&varempty, //Password
&varempty, //Add to recent files
&varempty, //WritePassword
&varempty, //ReadOnlyRecommended
&varempty, //EmbedTrueTypeFonts
&varempty, //SaveNativePictureFormat
&varempty, //SaveFormsData
&varempty); //SaveAsOCLetter
the error I get at runtime is:
This is not a valid file name.
Try one or more of the following.
* Check the path to make sure it was typed correctly.
* Select a file from the list of files and folders.
The path variable I am putting into myBString is correct ("W:\05\test\MailsortReport.doc") So I am assuming something is getting lost on the
BSTR parampass = (BSTR)myBString;
when I run it and check what is in parampass it just shows 87, and not a path.