excel - VBA to open Word document and refresh links -


I'm hoping to find a solution to my problem (or be a VBA). I ​​have a Word document in it which includes Linked Excel The tables are all the links work correctly, but I have to manually open the Word document to refresh the excel data. The reason for this is that I am using Word instead of Excel, because it contains large amounts of text.

Is there any way that I can program any type of code that is known through all the word documents in a folder, open each document, refresh all links, documents Saves, and moves on?

What I have is so far

  Sub OpenFiles () Dim MyFolder String Dim MyFile String MyFolder = "LOCATION" MyFile = Dir (MyFolder & In the form, "\ * docx") while myfile & lt; & Gt; "" Document. Open file name: = MyFolder & amp; "\" & Amp; MyFile MyFile = Dir loop and all  

UPDATE

OK, I was able to work open files! Now I write it up / save the file and try to close it

Error message:. ObjWord.Visible = true MyFolder = "LOCATION" MyFile = Dirf (MyFolder & amp; " . \ * Docx ") MyFolder string dim MyFile string is set as object objWord in the form of the object while doing MyFile & lt; & Gt; "" ObjWord.Documents.Open filename: = MyFolder & amp; "\" & Amp; MyFile Application.DisplayAlerts = False ActiveDocument.SaveAs file name: = MyFile Application.DisplayAlerts = True MyFile = Dirty Loop End Sub

You can try one of the following:

  while in the form of a slow objected object Myfile & lt; & Gt; Set "objDoc = objWord.Documents.Open (file name: = MyFolder & amp;" \ "& MyFile) objDoc.Save '~~ & gt; Save ObjDoc '~ ~ & Gt; Close myFile = Dir loop  

Or you can use the off method like it.

  objDoc.Close is true '~~ & gt; Set right with SaveChanges logic  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -