Hello,
I'm having problem with autofill
I think vb automatics "kill" blank spaces so when we write this
Dim s As String * 10
s = text1.Text
text1.MaxLength = 10
text1.Text = "hello"
Print Len(RTrim(s)) ' Prints "hello "
But I can't figure out how to do this in my code for print it...
I'm working on a application that replace fields in word and print it later
look at code of prog thats replace fields:
--
Private Sub Command1_Click()
Dim t1 As String
Dim t2 As String
Dim t3 As String
Dim t4 As String
Dim t5 As String
Dim t6 As String
Dim t7 As String
Dim t8 As String
Dim t9 As String
Dim t10 As String
Dim t11 As String
Dim t12 As String
Dim t13 As String
Dim t14 As String
Dim t15 As String
Dim t16 As String
Dim t17 As String
Dim t18 As String
Dim t19 As String
Dim t20 As String
Dim t21 As String
Dim t22 As String
Dim TextFill As String * 10
t1 = Text1.Text
t2 = Text2.Text
t3 = Text3.Text
t4 = Text4.Text
t5 = Text5.Text
t6 = Text6.Text
t7 = Text7.Text
t8 = Text8.Text
t9 = Text9.Text
t10 = Text10.Text
t11 = Text11.Text
t12 = Text12.Text
t13 = Text13.Text
t14 = Text14.Text
t15 = Text15.Text
t16 = Text16.Text
t17 = Text17.Text
t18 = Text18.Text
t19 = Text19.Text
t20 = Text20.Text
t21 = Text21.Text
t22 = Text22.Text
With wxcTest
.OpenDocument App.Path & "\RECIBO MATRIX.doc"
.ReplaceField "Nome1", RTrim$(t1)
.ReplaceField "CPF2", RTrim$(t2)
.ReplaceField "0,00", RTrim$(t3)
.ReplaceField "Dinheiro", RTrim$(t4)
.ReplaceField "Numeros", RTrim$(t5)
.ReplaceField "Banco2", RTrim$(t6)
.ReplaceField "Agencia2", RTrim$(t7)
.ReplaceField "Conta2", RTrim$(t8)
.ReplaceField "Nome2", RTrim$(t9)
.ReplaceField "Dia", RTrim$(t10)
.ReplaceField "Mes", RTrim$(t11)
.ReplaceField "ano", RTrim$(t12)
.SaveDocumentAs App.Path & "\teste2.doc"
.CloseDocument
End With
With wxTestOLE1
.Update
.Refresh
End With
End Sub
--
So I need that textbox + (blank spaces) upto MaxLength
I tryed to make it by the TextFill up there ( String * 10 )
Tryed to RTrim$(t1 & TextFill)
But it doesn't go to help as I need it Exactly the MaxLenght
Anyone can help me with this
I'm using own control (down here):
Public WA As Word.Application
Public Doc As Document
Public Function OpenDocument(strDocument As String) As Boolean
On Error GoTo CouldntOpen
Set WA = New Word.Application
WA.Visible = False
Set Doc = WA.Documents.Open(strDocument)
Doc.Select
OpenDocument = True
GoTo ItsOpened
CouldntOpen:
OpenDocument = False
ItsOpened:
'
End Function
Public Function CloseDocument() As Boolean
On Error GoTo CouldntClose
Doc.Close False
CloseDocument = True
GoTo ItsClosed
CouldntClose:
CloseDocument = False
ItsClosed:
'
End Function
Public Function ReplaceField(strField As String, strReplacementText As String) As Boolean
On Error GoTo ErrorOcurred
With WA.Selection.Find
.Text = "[" & Trim(strField) & "]"
.Replacement.Text = Trim(strReplacementText)
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
WA.Selection.Find.Execute Replace:=wdReplaceAll
ReplaceField = True
GoTo Success
ErrorOcurred:
ReplaceField = False
Success:
'
End Function
Public Function SaveDocumentAs(strNewName As String) As Boolean
On Error GoTo CouldntSave
Doc.SaveAs (strNewName)
SaveDocumentAs = True
GoTo ItsSaved
CouldntSave:
SaveDocumentAs = False
ItsSaved:
'
End Function
Public Function PrintDocument() As Boolean
On Error GoTo CouldntPrint
Doc.Application.PrintOut FileName:="", Range:=wdPrintAllDocument, Item:= _
wdPrintDocumentContent, Copies:=2, Pages:="", PageType:=wdPrintAllPages, _
Collate:=True, Background:=True, PrintToFile:=False
PrintDocument = True
GoTo ItsPrinted
CouldntPrint:
PrintDocument = False
ItsPrinted:
'
End Function
If anyone understand what a wrote above... Please help :]
Sorry for "bad" english
Thanks,
MavecO*
PS: I tryed to search but nothing helped me.

Help with Auto-Complete (Fill with blank)
Juergen Weis
Function PadSpaces(ByVal s As String, ByVal length As String) As String
If Len(s) < length Then s = s & Space(length - Len(s))
PadSpaces = s
End Function
Don't forget to remove the Trim() call in ReplaceField, it will remove the spaces you've added.
AmandaB
This is the CTRL that I've before:
Yo123
"Argument is not optional"
I'm trying to fix this...
If anyone can help It will be good =)
Thanks for help in this guys ;]~
MavecO*.
chadbengen
All codes helped a lot
but it says that's not optional
Michael McCormack - MS
Ok, I should have looked more shallow...!
It's in the code you marked red - The PadSpaces() method requires two parameters, 'x' and 'length', and you've only passed in one.
Since I can't add a new post, I'm trying to edit this one...
The answer your missing is that Trim() function... In the line of code:
.Replacement.Text = Trim(strReplacementText)
You don't want the Trim(). This is removing the spaces that you added using the Padding function. Try this instead:
.Replacement.Text = strReplacementText
That should work for you providing that you've added the padding to the variable that you pass into strReplacementText.
BTW, nobugz, I think it's kinda lame that you marked your own post as an answer and locked this thread... you may be correct with your answer, but the OP apparently didn't understand it. You should still allow someone else to try and get the point across...
Scott Michael
I've fixed the bug of Argument but it's not working yet!
I dunno why
See my codes:
Nick Ericson
KTsmom
ZJames Ma
gadym