Click here to Skip to main content
15,889,838 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have a VB6 program that allows use of a created object instance of MS Word to produce letters and automatically save them in the appropriate directory as determined by my program, for example:

objMSWordDocument.SaveAs C:\DISC\VER70\LOAN\DATA2\2\3\00049323.01\LETTERS\20140428124003.docx , wdFormatXMLDocument

This works as designed on one machine running Windows 8.1 Professional 64-bit, but on another identical machine, instead of silently saving the document to the specified location, a Save Dialog opens that points to the Windows user's Documents directory.

I assume this is a permissions issue, either in MS Word, or Windows 8.1. My program is set to Run as Administrator.
Posted
Updated 28-Apr-14 12:20pm
v2
Comments
Sergey Alexandrovich Kryukov 28-Apr-14 18:32pm    
There are too many ways of screwing up things. Without seeing your code, who will tell you where? You Word document component will save the file where you tell it to save.
It's worth to note that there are no such cases when a hard-coded path name can be useful. You need to have the path in some configuration date.
—SA
yakshasa 5-May-14 17:30pm    
I should have explained that the path is not hard-coded, and that the above is the path as assembled by a routine in our program. My question is, given that this is a verified path, why would the code work on one machine but not another machine configured the same way (as far as I can tell).

1 solution

Have a look here: Options.DefaultFilePath property[^] and set one of WdDefaultFilePath[^].

VB
Dim docPath As String
docPath = Application.DefaultFilePath(wdDocumentsPath) & "\" & Format(Date, "yyyyMMdd") & ".docx"
 
Share this answer
 
Comments
[no name] 24-May-14 20:07pm    
Guilty for another five

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900