Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get text from Word doc
#1
Trying to get text form doc file. I'm not figuring out a good way to do it.

Thanks,
jim
#2
Something like this?

Macro Macro6
Code:
Copy      Help
out
;declare Word type library (use 'Type libraries' dialog in Tools menu)
typelib Word {00020905-0000-0000-C000-000000000046} 8.0 0x409
;start Word, make visible, get Documents interface
Word.Application app._create
;app.Visible = TRUE
Word.Documents docs=app.Documents
;load file
VARIANT d=_s.expandpath("$desktop$\test.doc")
Word.Document doc=docs.Add(d)
;text
out doc.Content.Text
app.Quit
#3
Doesn't work.

Get error:
0x800A175D,

System Info:
Windows 7 Profession
Office 2010
#4
The library he gave you is for Word 2000 I'm pretty sure. You need the one for 2010...Correct me if I'm wrong?
#5
I used 'Type libraries' dialog in the Tools menu to change the "typelib Word ..."

typelib Word {00020905-0000-0000-C000-000000000046} 8.5
and even used:
typelib Word "$program files$\Microsoft Office\Office14\MSWORD.OLB" (which is a setting to use file path in the "Type libraries" dialog)

Still get the error.

It's Windows 7 Professional (64-bit) too. Forgot to mention that.
#6
You are running Windows 7/Vista right? So you might have to grant administrator permissions. Sorry I do not have office to test this.
#7
I don't know if that's it...but how would I go about granting administrator permission.

I am logged on as "administrator"

Hmm.
#8
Error (0x800A175D) means "Could not open macro storage."

Which is an error created when trying to "extract" the information from word.

Try using a different document, the one you're using could be corrupted.

Now the following I may be way off but read it over...

I looked in msdn and I found 2 possibility :
1 - normal.dot is corrupted
The Normal.dot template file used by Word might be corrupt. If you are encountering one of the errors described in the Summary section, you can temporarily rename the Normal.dot template to determine if it is the cause of the problem.
Renaming the Normal.dot template resets several options back to their default settings, including custom styles, custom toolbars, macros, and AutoText entries. It is strongly recommended that you rename the Normal.dot file rather than deleting it, so that you can restore these settings if the template is not corrupt.

Certain installations of Word may yield more than one legitimate Normal.dot file. These situations include multiple versions of Word running on the same computer or several user profiles on the same computer. In these situations, pay special attention so that you rename the correct copy of Normal.dot.

To rename the Normal.dot file follow these steps:

Quit all instances of Word, including WordMail.
On the Windows taskbar, click Start, point to Find, and click Files or Folders.
In the Named box, type Normal.dot.
In the Look In box, select your local hard disk drive (or an alternate user template location if you are running Word from a network server).
Click Find Now to search for the file.
For each occurrence of Normal.dot that appears in the Find dialog box, right-click the file. Click Rename on the shortcut menu. Give the file a new name, such as OldNormal.dot or Normal-1.dot.
Minimize the find dialog box.
Restart your automation client to start Word.


2 - problem of permission
To avoid the error, do one of the following:
Start Word as the Interactive User.
Start Word as a user with administrator rights.
Load the user hive for the user account programmatically, or have a dummy service that runs under the user account.
You must identify under what user account Word is running, and in what context you are developing. For example, if you are automating from a Microsoft Transaction Server (MTS) package, the default user account is IWAM_MachineName.
#9
TheVig Wrote:Doesn't work.

Get error:
0x800A175D,

System Info:
Windows 7 Profession
Office 2010

Try with IDispatch.

Macro Macro1543
Code:
Copy      Help
out
;start Word, make visible, get Documents interface
IDispatch app._create("Word.Application")
;app.Visible = TRUE
IDispatch docs=app.Documents
;load file
VARIANT d=_s.expandpath("$documents$\notes.doc")
IDispatch doc=docs.Add(d)
;text
out doc.Content.Text
app.Quit

Also try how works in exe. Let exe run as User.
#10
Still not working.

Not even in exe

Bummer.

The error is on "IDispatch doc=docs.Add(d)"
#11
Does it give same error this time as before?

Edit: Check this out... http://support.microsoft.com/kb/247028
#12
Renamed Normal.dot

No luck. Same error.


Forum Jump:


Users browsing this thread: 1 Guest(s)