Solved

Text documents (grabbing the first few sentences)

Posted on 2004-04-02
8
179 Views
Last Modified: 2010-04-15
Aright, I'm going to hell for asking this question (wait for it): how can I grab the first xxx about of characters from a text (I know this one), doc, or rtf file?
0
Comment
Question by:rossryan
  • 3
  • 3
  • 2
8 Comments
 
LVL 12

Expert Comment

by:dfiala13
ID: 10746285
You doing this on a server?  Or can you use Word automation?
0
 
LVL 2

Expert Comment

by:coltrane2003
ID: 10746395
Once you get the file contents read into a string you can use Substring. No offense if you already knew this much. Substring takes two arguments - the index of the first character and the index of the last character. You could do something like

aStringFormofsomeWorddoc.Substring(0,3);

Hope that helps
0
 

Author Comment

by:rossryan
ID: 10746417
It's the getting the file contents (particulary word documents) into the string that I am interested in ;).

What is word automation (api?).

I need to programmatically grab the first few sentences...i.e. I need an API or code that grabs it (for use in a program).
0
 
LVL 2

Expert Comment

by:coltrane2003
ID: 10746430
Word along with many other MS office products has a means of writing scripts. This is called VBA Visual Basic for applications. It's under tools/macro/visual basic editor. Perhaps this is what is meant by API?

Have you tried reading a .doc file with standard IO?

I've got to run now. If you haven't figured this out by the time I get back, I will try to help. Good luck.
0
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
LVL 12

Expert Comment

by:dfiala13
ID: 10746452
>>It's the getting the file contents (particulary word documents) into the string that I am interested in ;).
That's why I asked.  If you are running a Winforms app, you can use the Word automation objects to open and manipulate a document.  Using the Word objects it is relatively trivial to grab the the first X characters.
http://msdn.microsoft.com/vstudio/office/default.aspx?pull=/library/en-us/odc_vsto2003_ta/html/wordobject.asp

If however you are ripping through lots of documents being uploaded to a server, this might not be the best option,
0
 
LVL 2

Expert Comment

by:coltrane2003
ID: 10749079
Yes I agree with the above. It depends on what kind of solution you are trying to provide. A couple years back I worked with a content managment system that published web templates from Word. It worked with a VBA script and validated documents to be published against a DTD. I didn't build it so I'm afraid I don't know much about it.
0
 

Author Comment

by:rossryan
ID: 10749309
Right. Now, does this work with Office XP, or shall I install 2003? (I've been hoping to hold off on that one).
0
 
LVL 12

Accepted Solution

by:
dfiala13 earned 500 total points
ID: 10750642
Automation works bach as far as Word 6, so yes yuo can do it with Office XP.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now