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
Printable View
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
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.
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:
Option Explicit Private objWord As Object 'instead of Word.Application Private wd As Object 'instead of Word.Document 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 Private Const EM_FMTLINES = &HC8 Function SplitLinesIntoArr(Ctrl As TextBox) As String() Dim sTmp() As String, i As Long SendMessageByVal Ctrl.hwnd, EM_FMTLINES, True, 0 sTmp() = Split(Ctrl.Text, vbCrLf) For i = 0 To UBound(sTmp) If Right$(sTmp(i), 1) = vbCr Then sTmp(i) = Left(sTmp(i), Len(sTmp(i)) - 1) End If Next SendMessageByVal Ctrl.hwnd, EM_FMTLINES, False, 0 SplitLinesIntoArr = sTmp() End Function Private Sub Command1_Click() Dim sLinesInTextbox() As String Dim i As Integer sLinesInTextbox = SplitLinesIntoArr(Text1) For i = 0 To UBound(sLinesInTextbox) Debug.Print vbTab & sLinesInTextbox(i) Next i End Sub
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:
For i = 0 To UBound(sLinesInTextbox) strBuff = strBuff & vbTab & sLinesInTextbox(i) & vbCrLf Next i
You can output the Buffer (to Word) in your BookMrks/New Doc etc :)
Bruce.
Wow, I swear I learn more on here than in any book/online course.
You guys need to write a book :)
thanks again xx
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.
Quote:
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 :)?
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).
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:
MsgBox Join(strArr, ",")
That will join back the Array, seperated by ","
So, in your case, you could try:
VB Code:
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.
Opps, I missed a bit of the convo while I was typing/testing :)
Bruce hasd a point.
Bruce.
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