Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Extract Each Word From A String And Print One Word Per Line.


I have a textbox that contains a string(can be any number of words).

How do i extract each word from the string and
print one word per line onto the form? e.g.

textbox:
Hi can someone please help me

Print to form:
Hi
can
someone
please
help
me


Thanks




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Assign A String To Word Object To Print
Hi,
can anyone let me know how to print a string using the word application object model.

I think it should be simple but don't know the correct objects to use. Put simply I have a string which I want to print from VB, via MS word without showing the word application.

Thanks in advance.

Lenin

How Do I Read One Line Of String In An Active Document In MS Word?
Hello,

I'm writing a macro that needs to read every single line in an active document in MS Word. I think I need to use ActiveDocument, but don't know what method/property to use to read line by line. Please advice.


Thanks,

Word VBA / Macro Problem With Print & Browser (Word 2000)
I am trying to use a macro inside the AutoOpen() event of a Word doc so that when the Word doc is opened inside IE, it will print the Word doc then close both the Word doc and the IE window. For some reason, VBA loses its reference to the doc object and IE Application object after the PrintOut line is executed. I have tried things like:
 Sub AutoOpen()
    MyWord.Visible = False
    MyWord.ActiveDocument.PrintOut
    MyWord.ActiveDocument.Close False
End Sub
or:
Sub AutoOpen()
  With ActiveDocument
     .PrintOut Background:=False
     .Close savechanges:=False
     .Parent.Quit
  End With
End Sub
or:
Sub AutoOpen()
    Dim MyWord As Object
    Set MyWord = GetObject(, "Word.Application")
    Dim IE As Object
    Dim IEDoc As Object
    Set IE = GetObject(, "InternetExplorer.Application")
    Set IEDoc = MyWord.ActiveDocument
    IEDoc.PrintOut
    IEDoc.Close
    IE.Quit
End Sub

But whatever I try, the Word doc prints, then throws a 4605 error about the method or property not being available because the document is in another app. Any ideas?

Thanks,
Chris

Excel Closes, But Word Doesn't! And Word Won't Print!
Hello:
   My code needs to open Excel, populate a table with data, mail-merge that table with a Word document, and finally print the merged documents. I have two problems:

1) As the program finishes, Excel closes and is removed from the Task Manager's Processes list, but Word is not removed. I've tried the .Quit method for both (even accounting for Word's use of parameters), but "WINWORD.EXE" remains on the list even after "EXCEL.EXE" is removed. I also set my objects to Nothing in Class_Terminate, but still no luck - and putting the .Close/.Quit procedures under Class_Terminate gave me an error. I know Excel is working because the program is saving my .xls files, but I'm not sure about Word. Which leads to...

2) Obviously I'm only opening Word to merge the file - the text of the document itself never changes so it doesn't need to be saved, just linked to the data source (the Excel table just created). But I can't get Word to print! I set the .ActivePrinter property and used .PrintOut but no luck. What do I have wrong here? Thanks for any insight.

Jeff W.
Owen, Little and Assoc., Inc.
Beachwood, NJ

P.S. This code runs from within ArcMap, a digital-mapping software package. Hence all of the "ICommand"s and "IMap"s and such, the use of "ISelectionSet" to populate the Excel table, etc. All of the code pertaining to ArcMap works fine - it's mostly just the part at the end of the code relating to Word where there must be something I'm doing wrong.

Code:Option Explicit

Implements ICommand

Private m_pApp As IApplication                                         
Private m_pMxDoc As IMxDocument
Private m_pMap As IMap
Private m_pExt As IExtension
Private m_pFeature As IFeature
Private m_pFeatureLayer As IFeatureLayer
Private m_pFeatureCursor As IFeatureCursor
Private m_pFeatureSelection As IFeatureSelection
Private m_pSelectionSet As ISelectionSet
Private m_pFields As IFields
Private m_pField As IField
Private m_pRow As IRow
Private m_pCursor As ICursor
Private m_pQBLayer As IQueryByLayer
Private m_pBitmap As IPictureDisp

Private m_pAppExcel As New Excel.Application
Private m_pWorkbook As Excel.Workbook
Private m_pWorksheet As Excel.Worksheet

Private m_pAppWord As New Word.Application
Private m_pDocument As New Word.Document
Private m_pMailMerge As MailMerge

Private Sub Class_Initialize()
   Set m_pBitmap = LoadResPicture(101, vbResBitmap)         'Button icon
End Sub

Private Sub Class_Terminate()
   Set m_pApp = Nothing
   Set m_pMxDoc = Nothing
   Set m_pMap = Nothing
   Set m_pExt = Nothing
   Set m_pFeature = Nothing
   Set m_pFeatureLayer = Nothing
   Set m_pFeatureCursor = Nothing
   Set m_pFeatureSelection = Nothing
   Set m_pSelectionSet = Nothing
   Set m_pFields = Nothing
   Set m_pField = Nothing
   Set m_pRow = Nothing
   Set m_pCursor = Nothing
   Set m_pQBLayer = Nothing
   Set m_pBitmap = Nothing

   Set m_pAppExcel = Nothing
   Set m_pWorkbook = Nothing
   Set m_pWorksheet = Nothing

   Set m_pAppWord = Nothing
   Set m_pDocument = Nothing
   Set m_pMailMerge = Nothing
End Sub
'
'ICommand members
'
Private Property Get ICommand_Bitmap() As esriSystem.OLE_HANDLE
   ICommand_Bitmap = m_pBitmap
End Property

Private Property Get ICommand_Caption() As String
   ICommand_Caption = "200' List"
End Property
 
Private Property Get ICommand_Category() As String
   ICommand_Category = "Extending ArcObjects"
End Property

Private Property Get ICommand_Checked() As Boolean
   ICommand_Checked = False
End Property

Private Property Get ICommand_Enabled() As Boolean
   ICommand_Enabled = True
End Property

Private Property Get ICommand_HelpContextID() As Long

End Property

Private Property Get ICommand_HelpFile() As String

End Property

Private Property Get ICommand_Message() As String
   ICommand_Message = "Creates a 200' list for selected property and generates an Excel file (for mail merge)"
End Property
 
Private Property Get ICommand_Name() As String
   ICommand_Name = "ExtendingArcObjects_200FootList"
End Property
 
Private Property Get ICommand_Tooltip() As String
   ICommand_Tooltip = "Create a 200' list"
End Property

Private Sub ICommand_OnCreate(ByVal hook As Object)
   Dim a As New UID
   
   Set m_pApp = hook
   a.Value = "CmdToolbarExt.clsLaunchExtension"
   Set m_pExt = m_pApp.FindExtensionByName("200FootListExtension")
End Sub

Private Sub ICommand_OnClick()             ''MAIN BUTTON
   Dim a As Long              'Field (i.e. column) value
   Dim b As Long             'b-d: counters
   Dim c As Long
   Dim d As Long
   Dim lMaxSize(8) As Long             'Width of each field
   Dim sValue As String             'Current record's value (string)
   Dim lHolder As Long             'Temp. field width value
   Dim sFieldName(8) As String
   Dim sBlock As String
   Dim sLot As String
   Dim sFirstRecord As String              'Holds IDNum of 1st selected record
   Dim sFileName As String
   
   sFieldName(0) = "IDNum"
   sFieldName(1) = "Block"
   sFieldName(2) = "Lot"
   sFieldName(3) = "FULLNAME"
   sFieldName(4) = "ADDRESS"
   sFieldName(5) = "CITY"
   sFieldName(6) = "STATE"
   sFieldName(7) = "ZIP"
   sFieldName(8) = "PROPLOC"
   
   Set m_pMxDoc = m_pApp.Document
   Set m_pMap = m_pMxDoc.FocusMap
   Set m_pFeatureLayer = m_pMxDoc.FocusMap.Layer(0)         '!!Change to reflect name
   Set m_pFeatureSelection = m_pFeatureLayer         ' of parcel layer!!
   Set m_pCursor = m_pFeatureLayer.Search(Nothing, False)
                                                      
                                                                            'Create Excel file name
   Call m_pFeatureSelection.SelectionSet.Search(Nothing, False, m_pFeatureCursor)
   Set m_pFeature = m_pFeatureCursor.NextFeature
   sFirstRecord = "Block" & m_pFeature.Value(m_pFeature.Fields.FindField("Block")) & "Lot" & _
                  m_pFeature.Value(m_pFeature.Fields.FindField("Lot"))
   
   Set m_pQBLayer = New QueryByLayer
   
   With m_pQBLayer             'Select all parcels within 200 feet
      Set .ByLayer = m_pFeatureLayer             ' of the selected parcel
      Set .FromLayer = m_pFeatureLayer
      .BufferDistance = 200
      .BufferUnits = esriFeet
      .ResultType = esriSelectionResultAdd
      .LayerSelectionMethod = esriLayerSelectWithinADistance
      .UseSelectedFeatures = True
      Set m_pFeatureSelection.SelectionSet = .Select
   End With

   Set m_pSelectionSet = m_pFeatureSelection.SelectionSet
   Call m_pSelectionSet.Search(Nothing, False, m_pCursor)

   Set m_pFields = m_pCursor.Fields
   Set m_pRow = m_pCursor.NextRow

   m_pMxDoc.ActiveView.Refresh
 
'*******************************mostly ArcMap code above this line************
'*******************************mostly VBA code below this line***************
                                                     
   Set m_pAppExcel = CreateObject("excel.application")         'Create Excel instance
   Set m_pWorkbook = m_pAppExcel.Workbooks.Add         'Create workbook/worksheet
   Set m_pWorksheet = m_pWorkbook.Sheets.Add(After:=m_pWorkbook.Sheets(m_pWorkbook.Sheets.Count))
   
   Cells(1, 1).Value = "IDNumber"             'Field names
   Cells(1, 2).Value = "Block"
   Cells(1, 3).Value = "Lot"
   Cells(1, 4).Value = "Name"
   Cells(1, 5).Value = "Address"
   Cells(1, 6).Value = "City"
   Cells(1, 7).Value = "State"
   Cells(1, 8).Value = "ZIP"
   Cells(1, 9).Value = "Property Loc."
   
   m_pAppExcel.DisplayAlerts = False             'Kill first three sheets
   Worksheets("Sheet1").Delete
   Worksheets("Sheet2").Delete
   Worksheets("Sheet3").Delete
   m_pAppExcel.DisplayAlerts = True
   m_pWorksheet.Activate
   m_pWorksheet.Name = "200 Foot List"
   m_pWorksheet.Rows(1).Font.Bold = True
   
   c = 1
   d = 1
   
   Do While Not m_pRow Is Nothing             'Grab values from selection set
      c = c + 1
      
      For b = 0 To 8
         a = m_pFields.FindField(sFieldName(b))
         m_pWorksheet.Cells(c, d).Value = m_pRow.Value(a)         'Write value to record
         sValue = m_pRow.Value(a)
         
         If c = 2 Then             'Find the longest entry in each field
            lMaxSize(b) = Len(sValue)
         Else
            lHolder = Len(sValue)
            
            If lHolder > lMaxSize(b) Then
               lMaxSize(b) = lHolder
            End If
            
         End If
         
         d = d + 1
      Next b
      
      Set m_pRow = m_pCursor.NextRow
      d = 1
   Loop
                                                      
   If lMaxSize(0) < 10 Then lMaxSize(0) = 10         'Minimum widths for fields
   If lMaxSize(1) < 6 Then lMaxSize(1) = 6
   If lMaxSize(2) < 4 Then lMaxSize(2) = 4
   If lMaxSize(3) < 6 Then lMaxSize(3) = 6
   If lMaxSize(4) < 8 Then lMaxSize(4) = 8
   If lMaxSize(5) < 4 Then lMaxSize(5) = 4
   If lMaxSize(7) < 6 Then lMaxSize(7) = 6
   If lMaxSize(8) < 13 Then lMaxSize(8) = 13
                                                      
   m_pWorksheet.Columns("A").ColumnWidth = lMaxSize(0)         'Set field widths
   m_pWorksheet.Columns("B").ColumnWidth = lMaxSize(1)
   m_pWorksheet.Columns("C").ColumnWidth = lMaxSize(2)
   m_pWorksheet.Columns("D").ColumnWidth = lMaxSize(3)
   m_pWorksheet.Columns("E").ColumnWidth = lMaxSize(4)
   m_pWorksheet.Columns("F").ColumnWidth = lMaxSize(5)
   m_pWorksheet.Columns("G").ColumnWidth = lMaxSize(6)
   m_pWorksheet.Columns("H").ColumnWidth = lMaxSize(7)
   m_pWorksheet.Columns("I").ColumnWidth = lMaxSize(8)
   
   sFileName = "C:200FootList_" & sFirstRecord & ".xls"
   
   Call m_pWorksheet.SaveAs(sFileName)         'Save Excel file (for this instance)
   m_pAppExcel.DisplayAlerts = False
   Call m_pWorksheet.SaveAs("C:200FootListMerger.xls")         'Save dummy copy of Excel file
   m_pAppExcel.DisplayAlerts = True             ' for mail merge (always overwrites)
   Call m_pWorkbook.Close
   Call m_pAppExcel.Application.Quit             'Quit Excel
   
   Set m_pAppWord = CreateObject("word.application")         'Create Word instance
   m_pAppWord.ActivePrinter = "\DellserverSHARP407 on Ne04:"

                                                                            'Open document for mail merge
   Set m_pDocument = m_pAppWord.Documents.Open("C:MailMerge.doc")

   Call m_pDocument.MailMerge.OpenDataSource("C:200FootListMerger.xls")
   m_pDocument.MailMerge.Destination = wdSendToNewDocument
   m_pDocument.MailMerge.Execute

   Call m_pDocument.PrintOut             'Print letters
   Call m_pDocument.Close
   Call m_pAppWord.Application.Quit(False)             'Quit Word
End Sub

Extract Line By Line Of String Freom RichTextBox ..
anyone know how to do this????

i hope to extract line by line from Rich Text Box..... just like how the "line input" works ....

i have search through the forum but no one ever done this

Word: Counting A Specific String In A Word Document
Hi all,

After visiting the Word FAQ I couldn't find any clue for my query:
I would like to count (in VB) how many times the string "Yesterday"
appears in a word document I am working on.

By using the manual Replace function (replacing "Yesterday" by "Yesterday"),
Word tells you how many replacement it has done and therefore how many
instances of the string "Yesterday" were in the document.

Can anyone point me in the right direction about using VB to find out
how many times "Yesterday" appears in my document, please?

Many thanks
Francois

Extract A Word From A Web Page...
How would I go about getting a single word from a web page? Lets say I go to iwin.com and want to get the amount for icoins (points) that the user currently has and display it in a text box...how would I do that?

Extract Data From Word
Hi Guys,
I'm getting stuck on a little problem here:
I want to extract variable length data from a Word doc, I want to be able to create a string of all of the text starting below the greeting line in a letter of "Dear So & So" and finishing at the end of the line above "Yours sincerely" so I can do things with it in VB.
I'm a newbie to VBA, I've searched various forums but can't find an answer anywhere.
I can do the find for the start and finish of the document area concerned, but I don't know how to tell VBA where these start/finish points are, and how to copy a selection into a variable, or some format that I can then parse etc in VB.
Any help would be much appreciated.
Thanks,
Nick

HOW To Extract Word From A Sentence?
For example:
if user type "I love icecream"
how do i extract each word and put "I", "love", "icecream" into 3 different variables?
a="I" B="love" C="icecream"
thanks.....

Extract Bookmarks Value From Word.doc
Anybody please help me out how to extract bookmarks values from a word doc?


I have a word document with many bookmarks field named from Text1, Text2, Text3....etc.

What I did was:


Dim w As Word.Document
Dim a As Word.Application
Dim output1 As String

Set a = New Word.Application
Set w = New Word.Document
Set w = a.Documents.Open("c:my document est303.doc")

output1 = w.Bookmarks.Item(1) -> This only retreive BookMarks name as "Text1" The "Text1" current contains value "ABC Company". How to extract value from "Text1"?

Thanks.

To Extract The First Word From A Text Box
I need to extract the first word from data in a text box (up to the first space) to use in an sql statement. What is the best way to do this?

To Extract The First Word From A Text Box
I need to extract the first word from data in a text box (up to the first space) to use in an sql statement. What is the best way to do this?

Extract MS Word Information
Hi,

I have several (well, several hundred) word documents. I need to extract information from each such as Author, Date Created etc... how would I go about doing this for a single document?

Thanks.

Extract Data To Word
Hi there,
does anyone know of a compent that will allow me to place data I have in a Word document and save it from jmy vb application

Cheers in advance
Williery

Extract Text From Table In Word
Hi,
I've been skimming through the threads and couldn't find QUITE this question.

I have a word document, with text and tables here and there (I don't know where they are in the document - they're spread throughout it).

I want to know:
1) How can I find the first table, then the next then the next etc...
2) Can I just collect ALL of the tables in the word documents into one object?
3) Once I find a table, how can I extract text from a specific cell in it.
Maybe go over ALL the rows then ALL the cells and look for the text.

How can I do that?

Thanks a lot people!
You're great!

- M00gl3

Extract Bookmarks Value From Word.doc (part 3)
Hi RobDog888,

Thank you for your speedy response! ButI still get the same error.

1) How to iterate through the collection?

Label1.caption =””
For i = 0 to 41
Labe1.caption = Label1.caption ^ w.Bookmarks(i).Range.Text ^ chr(13)

Next i

The “for loop” does not work for w.Bookmark(i).Range.Text -> because Bookmarks is an object (or collection)?

Perhaps something like the following (I think)??

Dim cntrlItem as ?? (control, index…etc)
For each cntrItem IN ?? (collection, ?)

Next cntrlItem

Can you or someone fill the “??” blank?
Thank you.

Extract Bookmarks Value From Word Doc (Solved!)
Thank you very much. It works perfectly!!!!!

Extract Bookmarks Value From Word.doc (part 2)
Dim w As Word.Document
Dim a As Word.Application
Dim output1 As String

Set a = New Word.Application
Set w = New Word.Document
Set w = a.Documents.Open("c:my document est303.doc")

RobDog888
Ultra-Member

Registered: Apr 01
Location: Los Angeles, CA.
Posts: 2625

visual basic code:--------------------------------------------------------------------------------
msgbox w.Bookmarks("Text1").Range.Text


===========================================================================


Thank you very much, RobDog888.

Part 2:

I have about 42 bookmarks fields in a word doc. -> output1 = w.Bookmarks.Count /** to get the number of bookmarks in the doc.

Now I need to extract EACH of bookmarks value from the doc, and I think “for loop” should do it. However, I failed.

Dim CurrentField as String
Dim result as string

result = “”

For i = 0 to (a.ActiveDocument.Bookmarks.Count) - 1
CurrentField = w.Bookmarks.Item(i) -> Run-time error ‘5941’
-> The requested member of collection does not exit
result = result ^ w.Bookmarks(CurrentField).Range.Text ^ chr(13)

Next i


How to define “collection” for this case?

Your help is greatly appreciated.

Extract Text From Word Document
Hello all, I was wondering if anyone knows how to extract the text from a word document. The format is not important but I wish to reatin the whitespace, (tabs, spaces, newlines).

I've found lots of examples on how to save and create a word document but nothing on extracting text. Thanks for your help.

Extract Images In Word Document
Hi all,
i need to extract images stored in word document
it will be appreciatable if someone gives idea or code snippet
i used inlineshapes collection but not find solution

sankar

Extract Text From Word Document.
Hi,
I would like to write a class in VB 6.0, to extract text content from MSWord documents. Can anyone give me inputs on how to do this ?

Thanks!

Script Extract Embedded Files From Word
I have some Word 2003 docs that have many embedded Outlook 2003 .msg file objects, I want all those .msg files out and in a folder on my file system, if I try and click and drag them out I get a scrap error message, either way, I would rather do so with VBA for Office but I don't know how, there are many .msg files in the word doc (approx 50), will someone please let me know if this can be done with Office VBA

How Can I Extract Text From A Word Document TextBox
i have been working on word Document files.

each document has same text format.

i m using the code below to extract text from it,




Code:


Dim sFileName As String 'Name of files within the folder will be stored
Dim i As Integer 'This will count the files read***
Dim wrd As Word.Application
Dim wrdCount As Long 'Number of characters within the file
'Get the first file with extension "DOC" ***
sFileName = Dir$("C:Virology*.DOC") '***
Do While sFileName <> "" '***
Set wrd = New Word.Application 'Create obj of word application
wrd.Visible = False
wrd.Documents.Open "C:Virology" & sFileName
wrdCount = wrd.Documents(1).Characters.Count
Text1.Text = Text1.Text & vbCrLf & i & wrd.Documents(1).Range(0, wrdCount).Text
wrd.Documents(1).Close
Set wrd = Nothing
sFileName = Dir$ '***
i = i + 1
Loop







This works good for all the characters in the document but the problem rises when word textbox appears in the document.

Macro Word To Extract Words According To Dictionary
Hi, I need a macro word to extract words from a text in distinct languages. Looking at google, I found this code, but it doesn´t work with great texts (more than 1000 words).

Now, the code, open another document in which it copy the words that appear in the ms word dictionary. I thought that the solution can be to avoid this second document, and only remove the non dictionary words from the original doc.

Please take a look to the code, and tell me if you can help me! Thanks a lot!



Sub Macro1()
' ExtractNewWords Macro: Extracts words from your document
' that are not present in MS Word's spell-check dictionary
' Useful for terminology research
' Macro recorded on 14.08.02 by Tanya Harvey
'
' If no Word document is open
On Error GoTo MainStop
If Documents.Count = 0 Then
WordBasic.MsgBox "Open the document from which you wish to extract the words that are not present in MS Word's spell-check dictionary!"
Exit Sub
End If
' If more than one Word document is open
If Documents.Count > 1 Then
WordBasic.MsgBox "Close all Word documents and open only the document from which you wish to extract the words that are not present in MS Word's spell-check dictionary!"
Exit Sub
End If
' Declaration in confirmation dialogue box
Dim Prompt As String
Dim Title As String
Dim Response As String
Dim Style As Integer
Dim lingo As String
lingo = ActiveDocument.AttachedTemplate.LanguageID
For Each la In Languages
x = Application.Languages(la).ID
If x = lingo Then
lingo = la.NameLocal
End If
Next la
Prompt = "Is the language of your document <" + lingo$ + ">?" + Chr(13) + "(If not, click <No> and set the correct language!)" + Chr(13) + "" + Chr(13) + "This operation may take a while..."
Style = 36
Title = "Document language setting"
Response = MsgBox(Prompt, Style, Title)
If Response = vbNo Then
MsgBox "To set the language of your document, select:" + Chr(13) + "" + Chr(13) + "Edit/Select All" + Chr(13) + "Tools/Language/Set Language (select your language)" + Chr(13) + "Default/Yes/OK"
Exit Sub
Else
' Open a new document in which to save the words
Set doct = Documents.Add
' Arrange open windows
Windows.Arrange
' Activate the document from which to extract the terminology
Dim AnzahlFenster As Integer
Dim NummerAktivesFenster As Integer
AnzahlFenster = Application.Windows.Count
NummerAktivesFenster = Application.ActiveWindow.Index
If AnzahlFenster > NummerAktivesFenster Then
Application.ActiveWindow.Next.Activate
Else
Application.Windows(1).Activate
End If
' Select the entire content of the document
Selection.WholeStory
' For each word in the document do all instructions up to "Next"
For Each mot In Selection.Words
' If the word is not present in MS Word's spell-check dictionary
If mot.GetSpellingSuggestions.SpellingErrorType = wdSpellingInDictionary Then
' Activate the document listing the words extracted
doct.Activate
' Remove any additional spaces after the word
mot = Trim(mot)
' Type the word in the list…
Selection.TypeText mot
' … followed by a paragraph mark
Selection.TypeParagraph
End If
Next
WordBasic.MsgBox "End of spell check: All the words not present in MS Word's spell-check dictionary have been written to a separate file. Duplicates have been removed."
End If
MainStop:
If Err.Number <> 0 Then
MsgBox "An error has occurred. Make sure that the dictionary for the language of your document is installed (search your hard drive for <*.lex> to locate the dictionary files.)"
End If
End Sub

Extract Data Grid To Word Document
I am working on a Visual Basic project. Right now, I'm working on a query builder. Once the criteria is set and the query is ran, the data will show up in a data grid. I was wondering how I can extract this data (from the data grid) to a Word document.

Using VBA To Extract Dates From Multiple Word Files To Rename Them?
Application: Word 2002
Code: VBA
Problem: I need the ability in VBA to extract the date multiple files were either created or last modified so i can then prefix the existing file with the date.

ie:
file.doc > 20070416-file.doc
file2.doc > 20070416-file2.doc
file3.doc > 20070411-file3.doc


I have found some code to read a directories list of files into a list box, and now i need the ability to be able to read the created / last modifed date in a similar way.

Here is the code to read the contents to a list box:

Code:
Dim MyFile As String
Dim Counter As Long

'Create a dynamic array variable, and then declare its initial size
Dim DirectoryListArray() As String
ReDim DirectoryListArray(1000)

Dim DirectoryListArray1() As String
ReDim DirectoryListArray1(1000)
'Loop through all the files in the directory by using Dir$ function
MyFile = Dir$("c: est*.*")
Do While MyFile <> ""
DirectoryListArray(Counter) = MyFile

MyFile = Dir$

Counter = Counter + 1
Loop

'Reset the size of the array without losing its values by using Redim Preserve
'ReDim Preserve DirectoryListArray(Counter - 1)

'To prove it worked you could run the following:

For Counter = 0 To UBound(DirectoryListArray)
'Debug.Print writes the results to the Immediate window (press Ctrl + G to view it)'
Debug.Print DirectoryListArray(Counter)
Next Counter

'To populate a Listbox from the array you could use:

ListBox1.List = DirectoryListArray


Any ideas?

Thanks in advance

Read A Word In A Line Of Text And Delete That Line
I have some aim logs that I'm going to put in .txt format, and I want to be able to delete the text that the other person has written.

Is there a way for me to specify a screen name and have the program delete that line of text?

Thanks,
Brad

Looping Through A File In Word, Line By Line
Hello there. These Forms have gotten me decent with VB6 + Excel and now I have to learn Word. I've searched the forms and found how to load the word document I need to use, so that's fine. In the document there is a series of tables, and then some normal lines of text. I need to search though the normal lines of text until I find a "$" symbol. How do I loop through the lines in a word file?

Any hints would be great.

Merge Word Files And Print To PDF Print
Looking for code would allow me to merge multible word files into a single file and print to a single pdf file.

New Line In MS Word
Hail,

I'm a relative newcomer to the Visual Basic scene. I am creating an application which will guide the user through a screener process and then output a few Word Documents to be printed based on the information gathered.

My issue is rather simple and I feel foolish for asking, but better to get it done and over than to remove what is left of my hair. I decided to create the documents strickly in Visual Basic Code. After entering a Single line and setting its font properties as well as alignment, i cant for the life of me figure out how to move the cursor down to the next line so i could continue to write the heading. How do i move the range down to the next line in the document with Visual Basic.NET?


The first line of text doesn't fill the entire line so the cursor doesn't automatically jump to the next line

-Thanks in advance

Getting Word Out Of Line
Heres my problem. I recive a line from a chat, and lets say I want to trigger my program to respond when some one types "/ask, blah blah" the /ask must be there for it to activate, the blah is anything they want. I can get it to work with just "/ask", but when there is extra words it will not detect it. I need something that will look for the "/ask" and ignor all the other junk.

If Text1.Text = Text2.Text + ("/ask") Then

I'm having a hard time with that.
Text1.text recieves the whole line, Text2.text recives just the person's user name.


Thanks.

Getting The Last Word In Each Line
i need to get the last word in every line in a textbox (in my case it would always be 25 or less)

i thought if i could decleare a variable and get each line in each variable:

Dim LastWord (1 to (txtInput.lines)) as string, X as integer
x=0
do
Lastword(x)=line input (txtInput.text)
x=X+1
on error exit do (does this work?)
loop

i know this wont work, but i guess you get the idea what im thinking of

and then i could use the InStrRev function to get the last word

Thanks in Advance
SUMMER IS HERE !!!!

Print To Word
I looked arround but could't find anything...

I want to be able to print to Word, eather the current frame ot the current record. How do I do this?
is there samples out there...

Vb _ Ms Word Print
hi,

my code is

printer.font.size=14
printer.font.bold=true
printer.print "My company Name"
printer.font.size=10
printer.font.bold=false
printer.print "some text"
..
.
.
.
printer.enddoc
====

now in printer

My Company Name
some text

was printed


all i want is - to store the output in to a word document (no previews pls)

thanks in advance
ackid32

Word Does Not Print
Hello to all,

word2000 and vb6

When I run this in debug mode, I get me letters.
If I run this in RUNTIME mode, I get no letters.

here is where I think it does not work


objWordDocuments.Application.PrintOut



Do anyone have any idea what is going on here.

I spend a week on this but could not figured it out.

thanks a bunch.

Private Sub CmdCustomerLetter_Click()
call InitilizeWord
call CheckedBoxSelected
end sub

Private Sub InitilizeWord()

'CREATE MS WORD APPLICATION OBJECT.
If TypeName(objWordApplication) = "Application" Then
Set objWordApplication = GetObject(, "Word.Application")
Else
Set objWordApplication = CreateObject("Word.Application")
End If
Set objWordDocuments = objWordApplication.Documents
Exit Sub
end sub

Private Sub CheckedBoxSelected()
Dim k As Integer


If Me.LvwCust.ListItems.Count > 1 Then
For k = 1 To Me.LvwCust.ListItems.Count
If Me.LvwCust.ListItems.Item(k).Checked Then
Call GetBkMark(k)
End If
Next k
End If
End Sub

Private Sub GetBkMark(ByVal SelItemIndex As Integer)
'*************************************************************************************************** *****************


Dim strPathName As String
Dim strFileName As String
Dim j As Integer
Dim objTemplate As Word.Document
Dim k As Integer


strPathName = App.Path & ""
strFileName = "Customer.dot"

Set objWordDocuments = objWordApplication.Documents
'Set objTemplate = objWordDocuments.Add(strPathName & strFileName, True, wdNewBlankDocument, True)

For k = 1 To Me.LvwCust.ListItems.Count
If k = SelItemIndex Then
Set objTemplate = objWordDocuments.Add(strPathName & strFileName, True, wdNewBlankDocument, True)
With objTemplate

If .Bookmarks.Exists("CustName") Then
.Bookmarks("CustName").Range.text =Trim(Me.LvwCust.ListItems.Item(k).SubItems(2)) & " " & Trim(Me.LvwCust.ListItems.Item(k).SubItems(1)))
End If
'ADDRESS
If .Bookmarks.Exists("Address") Then
.Bookmarks("Address").Range.text = Trim(Me.LvwCust.ListItems.Item(k).SubItems(5)))
End If
objWordDocuments.Application.PrintOut
End With
End If
Next k
End Sub

Print Word Doc...
I am using the following Sub to print a word document, but there are problems with it. I think the issue is the wordDoc.Close or Word.Quit lines. If I set the Word.Visible property to true, I get a 'Do you wish to close without finishing printing?' warning at one of these points, (I haven't bothered to check which), but I'd rather Word is not Visible, and so I need a way to make sure Word has sent the print job before executing these lines...
How can I do that?



Code:
Public Sub PrintWordDocument(FileName As String)
On Error GoTo WordError
Dim Word As Word.Application 'Opens word
Dim wordDoc As Word.Document 'creates document

frmInfo.Show
frmInfo.SetLabel ("Printing Word Document." & Chr(13) & "Please Wait...")
frmInfo.ZOrder 0

Set Word = CreateObject("Word.Application")
Set wordDoc = Word.Documents.Open(FileName)
Word.Visible = True 'False
wordDoc.PrintOut 'Prints Word Document
wordDoc.Close (wdDoNotSaveChanges) 'Close word without saving
Word.Quit

frmInfo.CloseWindow
Exit Sub

WordError:
frmInfo.CloseWindow
warning = MsgBox(Error, vbOKOnly, "Error!")
Set Word = Nothing
Set wordDoc = Nothing
End Sub

Print In Word
Hi!
I'm printing datas from vb with Word and I don't want the user to see anything.
When the user press the print button,
Word opens and set all the values correctly. Word is not visible.

Then I ask to print the document and to close Word.

The problem is that some printers don't have the time to spool the document before Word closes....

So it doesn't print....

If I cancel the Word close, it prints well.

So I need to make Word active until the document is spooled. And then close....

Any ideas????
tks!

Can You Print A Word Doc From A Web App?
I am trying to print a word doc (over our intranet) using vb.net and office 2000, and am having no luck. Is this not possible, or am I doing it wrong.

    When I attempt to execute this code I get the following error message: Server execution failed. I have included reference to the Word Library in my project. I have changed my path from the actual path to the virtual path and everything else I could think of to no avail.

Here is the code:
Code:Imports Word
Imports System
Imports System.Diagnostics
Imports System.ComponentModel

Public Class frmConfirm
    Inherits System.Web.UI.Page
    PrintDoc = "\bblweb
taspHirePacketHPDocs1.doc"
    Dim w As Word.Application
    Dim d As Word.Document
    w = New Word.Application
    d = w.Documents.Open(PrintDoc)
    d.PrintOut(False)
    d.Close()
    w.Quit()
    w = Nothing
End Sub


I have never posted a question on a site before and if I have done so incorrectly please tell me the correct way to do it.
and thanks,


 

How Do I Print A Two Or More Line String From A Text Box To A Sheet Of Paper?
I have my whole program done and error tested... I just have one last thing to fix before I am done.

please help...


I have a text25 that has the value of "blah....... blah" that take's up 2 lines on a shet of paper. Now it just prints the first line untill it runs out of paper.... how do I get it to print all the text on multilines of paper?

Thanks a mill!

Select Line Word Vba
If you double click in the margin of word the entire line is selected.

I wanted to use the macro recorded to write a macro which selects the entire line. However, the macro recorder does not let me use the mouse in word.

2 questions

1) Is there a way to write a macro to select a line?
2) Why can't the mouse be used when recording a macro?

Line Numbers In Word And VBA
I've been going round and roud a couple of days one this. Perhaps someone can enlighten me a bit.

My macro runs through what could potentially be a long, multi-page document. The macro is doing some relativly simple reformating of many lines(each line is a paragraph) depending on what characters are found in the line.

Briefly:

The macro searchs for a character at the beginning of a line
The line number is saved to a variable e.g. LineNum1
A second, different character is searched and it may or may-not be in the same line.
The line number of this line is saved to another variable e.g. LineNum2

The variables are captured with:

LineNum1 = Selection.Information(wdFirstCharacterLineNumber)

useing the following VBA script:

Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=LineNum1


does not necessarly work once the macro progresses through page 1 of the document since line numbering always restarts with a new page. If LinNum1 is equal to 3, then line number 3 on page one is always returned to even if you are on page 22!

The page number can be saved with:

PageNum = Selection.Information(wdActiveEndPageNumber)

but in the "Selection.GoTo" I can find no way to specify both page and line number.

------

Another possible avenue is via File, Page Setup, Line Numbers which can show consecutive line numbers across pages from document start to finish. You can

Selection.GoTo What:=wdGoToLine, Which:=wdGoToAbsolute, Count:=285

for example and go directly to what ever page line number 285 is on.


However, this "overall line number" is not what is captured with

Selection.Information(wdFirstCharacterLineNumber)

and I know of no way to capture it.

Since part of the macro is deleting lines as it goes in some cases, line numbers are dynamice and have to be captured as they are needed.

----------

I would think there would be some simple way to just say "goto line number 5 on page 12" but so far I am baffeled by this simple need.


Any help would be apprecated.

Thanks

David T.

Delete A Line In Word
is there a way to delete a particular line in word which is part of bookmark? I don't even see a way to skip to certain line of a bookmark and then delete. If I can get the line number and delete that particular line, then I can do something. Thanks

Lina

Grabbing A Line From Word
I need to read word documents using visual basic, like i would read a normal text-file. is this possible and ifso how would i do this.

Getting A New Line Indecation From Word
i'm using: WithEvents WordApp As Word.Application
WordDoc As Word.Document and i can obtain quite a few properties: such as underlined word, font properties, etc.
But i simply ran out of ideas on how to find a simple new line inside a word document.
any help would be much appreciated.

Reading Nth Word From A Line
Hello, I was wondering if you guys could help me out with something.
I am making a program to read a text file. The file has many many lines and it has words separated by spaces, is there a way to read lets say the 9th word of the line? And repeat?

Getting Word Line Number With VBA
Hi,

How do I get the absolute line number of a given cursor position in the word document. Absolute, and not the relative line number you see at the Word 2000 status bar(bottom) which is relative number to the current page.

When I get the absolute line number of a position, I must be able to go back to the same position using "CTRL+G > Line > enter value"

Please assist
Thank you

Subtracting Word From Line
I know you can add things to a line by going + "whatever", but I wanted to know how to minus a word from a line. Lets say the line was '(Enter)> Cow' and I want to subtract the (Enter)> from the line. How would I do that? I've tried the '-' sign but I always get an error.


Thanks.

How To Insert A Line In Word?
Hi All,
Please solve the following problem for me.

I want to insert a new picture of line in my word document through word. how can i do that ??
is it possible for me to format the content of the data as follows??
name : Ramanjaneyulu Narra
father's name : Hanumantha Rao
address : Inida
__________________________________________________(this is the line picture i want to insert)
Education : B.Tech
Branch :CSE
Year of Passing :2005

when i tried to do this using the spaces i was not able to do it completely.

Please solve the above 2 probelms for me as soon as possible.
I will be greatful to all those who responds to this mail.

Regards
Ramanjaneyulu Narra

Vba - Current Line In MS Word
This is so stupidly simple I can't believe I can't figure it out.
I need to have vba code identify what line of the page I am currently
on in an MS Word Document.

Not which paragraph or anything, just what line of the current page.

I can see how to change the # of lines per page, and how to get the
curLine in a Text Box, and the object.line property of a TextStream,
but nothing for what I am hunting for. I checked the Pages collection
in MSDN and couldn't identify any property for current line.

I'm emabarrased to have to even ask the question, but does anyone know
the answer?

Copyright © 2005-08 www.BigResource.com, All rights reserved