Results 1 to 11 of 11

Thread: the 'immeadiate' window :nvm. RESOLVED

  1. #1

    Thread Starter
    Fanatic Member evexa's Avatar
    Join Date
    Apr 2003
    Location
    USA
    Posts
    609

    the 'immeadiate' window :nvm. RESOLVED

    Does anyone know how to get the text out of the immediate window and into a word doc.

    would it be soemthing like:

    debug.text (as the data in the immediate)

    Also - if i use this method, will it still work in the compiled version?

    THanks guys xx
    Last edited by evexa; Dec 2nd, 2003 at 08:57 PM.
    Trust no one

    ----------------------------------------
    http://www.eccentrix.com/members/xeaudrey/exanegotium.html
    http://www.eccentrix.com/members/xeaudrey/

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Debug.Print places the text in the Immediate Window but these statements are not included in compiled applications. There is no Immediate Window at run-time.

  3. #3

    Thread Starter
    Fanatic Member evexa's Avatar
    Join Date
    Apr 2003
    Location
    USA
    Posts
    609
    Blimey!
    So how on earth do i get the text i put in there to go somewhere else?


    this is the code Im using, it indents a paragraph of text:
    any idea what I can do instead?
    THanks dood xx
    VB Code:
    1. Option Explicit
    2. Private objWord As Object 'instead of Word.Application
    3. Private wd As Object  'instead of Word.Document
    4.  
    5.  
    6. Private Declare Function SendMessageByVal Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
    7. Private Const EM_FMTLINES = &HC8
    8.  
    9.  
    10. Function SplitLinesIntoArr(Ctrl As TextBox) As String()
    11.     Dim sTmp() As String, i As Long
    12.     SendMessageByVal Ctrl.hwnd, EM_FMTLINES, True, 0
    13.     sTmp() = Split(Ctrl.Text, vbCrLf)
    14.     For i = 0 To UBound(sTmp)
    15.        If Right$(sTmp(i), 1) = vbCr Then
    16.           sTmp(i) = Left(sTmp(i), Len(sTmp(i)) - 1)
    17.        End If
    18.     Next
    19.     SendMessageByVal Ctrl.hwnd, EM_FMTLINES, False, 0
    20.     SplitLinesIntoArr = sTmp()
    21. End Function
    22.  
    23. Private Sub Command1_Click()
    24.     Dim sLinesInTextbox() As String
    25.     Dim i As Integer
    26.     sLinesInTextbox = SplitLinesIntoArr(Text1)
    27.     For i = 0 To UBound(sLinesInTextbox)
    28.         Debug.Print vbTab & sLinesInTextbox(i)
    29.     Next i
    30. End Sub
    Trust no one

    ----------------------------------------
    http://www.eccentrix.com/members/xeaudrey/exanegotium.html
    http://www.eccentrix.com/members/xeaudrey/

  4. #4
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Instead of outputting to the Debug (Immediate Window) build a String Buffer, and output that out to a .doc File (youv'e done that before).
    VB Code:
    1. For i = 0 To UBound(sLinesInTextbox)
    2.         strBuff = strBuff & vbTab & sLinesInTextbox(i) & vbCrLf
    3.     Next i

    You can output the Buffer (to Word) in your BookMrks/New Doc etc

    Bruce.
    Last edited by Bruce Fox; Dec 1st, 2003 at 08:17 PM.

  5. #5

    Thread Starter
    Fanatic Member evexa's Avatar
    Join Date
    Apr 2003
    Location
    USA
    Posts
    609
    Wow, I swear I learn more on here than in any book/online course.
    You guys need to write a book
    thanks again xx
    Trust no one

    ----------------------------------------
    http://www.eccentrix.com/members/xeaudrey/exanegotium.html
    http://www.eccentrix.com/members/xeaudrey/

  6. #6
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Blimey, eh!

    Why don't you just move the textbox data into Word directly as a Paragraph and then indent the Paragraph. Remember, if it can be done within the Word application, it can be done in VB using the Word automation server.

    [edit]
    I did not see Mr. Fox's post before I sent this reply. His method will work as well.

  7. #7

    Thread Starter
    Fanatic Member evexa's Avatar
    Join Date
    Apr 2003
    Location
    USA
    Posts
    609
    Originally posted by brucevde
    Blimey, eh!

    Why don't you just move the textbox data into Word directly as a Paragraph and then indent the Paragraph. Remember, if it can be done within the Word application, it can be done in VB using the Word automation server.

    Is there somewhere where I can fins these word things. Like indenting a paragraph - that would be very helpful ?
    Trust no one

    ----------------------------------------
    http://www.eccentrix.com/members/xeaudrey/exanegotium.html
    http://www.eccentrix.com/members/xeaudrey/

  8. #8
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    If you have a reference to the Word Object Library in your VB project, then hit F2 to bring up the object browser. In the top combobox select Word. This will allow you to see all the objects, collections, methods etc. of the Word Automation server (and there are a lot). Using these you can do anything to a document that you can do in Word.

    Also, to bring up more help, select an object in the left pane and hit the Help button (question mark) at the top. Providing everything is installed properly this should bring up the help file for Word (or maybe its Office).

  9. #9
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    VB6 has the Join Function, it will concertrate a String Array.

    You can use it instead of the For i Next.

    This is an example:
    VB Code:
    1. MsgBox Join(strArr, ",")

    That will join back the Array, seperated by ","


    So, in your case, you could try:
    VB Code:
    1. strBuff = vbTab & Join([b]sLinesInTextbox[/b], vbCrLf + vbTab)

    May be worth a try (replaces your For Next)

    Note: The use of the vbTab prior to the Join!






    Bruce.


    Bruce.

  10. #10
    INXSIVE Bruce Fox's Avatar
    Join Date
    Sep 2001
    Location
    Melbourne, Australia
    Posts
    7,429
    Opps, I missed a bit of the convo while I was typing/testing


    Bruce hasd a point.





    Bruce.

  11. #11

    Thread Starter
    Fanatic Member evexa's Avatar
    Join Date
    Apr 2003
    Location
    USA
    Posts
    609
    Something wierd happened to the text i indented...

    I typed in this:

    This is the quote that i want to test for repeating sentences......whyaifhskiufoeuifroewiuroweiuoweiuroiuwer

    and it indented it but repeated sentances and ended up like this:

    This is the quote that i want to test for repeating
    This is the quote that i want to test for repeating
    sentences......whyaifhskiufoeuifroewiuroweiuoweiuroi
    This is the quote that i want to test for repeating
    sentences......whyaifhskiufoeuifroewiuroweiuoweiuroi
    uwer

    Instead of just indenting what i had.

    Note: This must be done within the program not as it gets tranferred to word...

    Will using 'join' get rid of that problem?
    THanks guys in advance xxxxx
    Trust no one

    ----------------------------------------
    http://www.eccentrix.com/members/xeaudrey/exanegotium.html
    http://www.eccentrix.com/members/xeaudrey/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width