ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   Using Macro to Close Word File (https://www.excelbanter.com/excel-discussion-misc-queries/249877-using-macro-close-word-file.html)

dwake

Using Macro to Close Word File
 
I need to use an excel macro to close a word file....any suggestions?

Jacob Skaria

Using Macro to Close Word File
 
Try the below. Make sure the name of word document is typed correctly....

Sub ControlWord()
Dim appWord As Object
Set appWord = GetObject(, "Word.Application")
appWord.Documents("Content Management.doc").Close False
End Sub

--
Jacob


"dwake" wrote:

I need to use an excel macro to close a word file....any suggestions?


dwake

Using Macro to Close Word File
 
Tried that and it didnt work. The problem I'm having is closing the word
document after it has been used. Here is my code below. Any help would be
appreciated.

Sub WordToExcel()
Dim MyWd As Object
Set MyWd = GetObject("Audit Tracking.doc")

MyWd.ActiveWindow.Selection.WholeStory
MyWd.ActiveWindow.Selection.Copy

Sheet8.Range("A1").PasteSpecial xlPasteValues
End Sub


"Jacob Skaria" wrote:

Try the below. Make sure the name of word document is typed correctly....

Sub ControlWord()
Dim appWord As Object
Set appWord = GetObject(, "Word.Application")
appWord.Documents("Content Management.doc").Close False
End Sub

--
Jacob


"dwake" wrote:

I need to use an excel macro to close a word file....any suggestions?


Jacob Skaria

Using Macro to Close Word File
 
Try

Sub ControlWord()
Dim appWord As Object
Set appWord = GetObject(, "Word.Application")
appWord.Documents("Audit Tracking.doc").ActiveWindow.Selection.Copy
Range("A1").PasteSpecial xlPasteValues
appWord.Documents("Audit Tracking.doc").Close False
End Sub

--
Jacob


"dwake" wrote:

Tried that and it didnt work. The problem I'm having is closing the word
document after it has been used. Here is my code below. Any help would be
appreciated.

Sub WordToExcel()
Dim MyWd As Object
Set MyWd = GetObject("Audit Tracking.doc")

MyWd.ActiveWindow.Selection.WholeStory
MyWd.ActiveWindow.Selection.Copy

Sheet8.Range("A1").PasteSpecial xlPasteValues
End Sub


"Jacob Skaria" wrote:

Try the below. Make sure the name of word document is typed correctly....

Sub ControlWord()
Dim appWord As Object
Set appWord = GetObject(, "Word.Application")
appWord.Documents("Content Management.doc").Close False
End Sub

--
Jacob


"dwake" wrote:

I need to use an excel macro to close a word file....any suggestions?



All times are GMT +1. The time now is 03:51 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com