ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Updating a word count from a wrod file into excel (https://www.excelbanter.com/excel-programming/418043-updating-word-count-wrod-file-into-excel.html)

Laebrye

Updating a word count from a wrod file into excel
 
Hi everyone,

My VBA knowledge isn't the best, so this may not even be possible. I've
looked through the functions and the data link options and not found anything
that will work - so far.

I'm hoping that someone can give me a rough idea of the sort of code I would
need to update the word count from a word document into a cell in excel.

Dave

joel

Updating a word count from a wrod file into excel
 

Sub Test()

'
FName = "c:\temp\abc.doc"
WordWasRunning = True

On Error Resume Next
Set WDApp = GetObject(, "Word.Application")
If Err.Number < 0 Then
Set WDApp = CreateObject("Word.Application")
WordWasRunning = False
End If

WDApp.Visible = True 'at least for testing!

Set WDDoc = WDApp.documents.Open(Filename:=FName)
Count = WDDoc.Words.Count
Range("A1") = Count

WDDoc.Close

End Sub

"Laebrye" wrote:

Hi everyone,

My VBA knowledge isn't the best, so this may not even be possible. I've
looked through the functions and the data link options and not found anything
that will work - so far.

I'm hoping that someone can give me a rough idea of the sort of code I would
need to update the word count from a word document into a cell in excel.

Dave



All times are GMT +1. The time now is 04:39 PM.

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