Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word Macro Not Inserting Latest Version of Text File

Status
Not open for further replies.

jtrapat1

Programmer
Jan 14, 2001
137
0
0
US
I'm using office 97 and I have a word macro which inserts a text file from the server (along with several pie charts).
I dynamically write a text file to the server and insert this text file into the word document.
If the user launches the word document a second time, I want to delete the text file out there on the server, create a new text file, and then insert this latest copy into the word document.
The problem is that the macro inserts the old text file and never grabs the latest copy.
I delete the old file from a c program with this code:
------------------------------------------
sprintf(path,"/home/winshares/Data/wam%s/% d/yb_appr.doc",state.code,state.bu
dget_yr);
filename = path;
remove(filename);
fh = fopen(filename,"w");
-----------------------------------------
Then, inside the macro with vba code, I insert the new text file with this code:
-----------------------------------------
Selection.InsertFile FileName:=FileNm, Range:="", _
ConfirmConversions:=False, Link:=False, Attachment:=False
-----------------------------------------
Does anyone see anything wrong with this code or is there some parameter that I can specify so that the old text file will not be cached and that I can get the latest version of the text file?

Thanks in Advance.
John
 
No reason why you should have to specify anything about caching. Is the newest file there when you check using Windows Explorer? Did the code that generates the new text file explicitly CLOSE it?
Rob
 
Rob,
Thanks for the response.

Yes, when I check in windows explorer, the new file is there.
And, I do explicitly close the file.

Is there anything else you can think of as to why my file is not updating?

Thanks
John

 
What sequence of actions causes, in your case, the new text file to become available (e.g., in order of severity, shut down and restart macro, close and reopen document, shut down and restart Word, restart Windows). That will help clarify the source of the problem.
Rob
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top