special characters from vba

P

Pedro Leite

Good Morning

I have a bit of code that opens a new word doc, fill the document with excel
data, prints, close and so on
the thing is, the document is tabular and is limeted in row and columns with
" - " and " | "

example : ( make the window larger to fit )

now what i want is to use the box drawing characters available in the
extended ascii table ( corners, junction lines and so on ) asc 186 , 205 and
some others.

the font used is courier new and has a sub set, called box drawing that has
these caracters. how can i use them ??

thank you

Pedro Leite from Portugal.





-------------------------------------------------------------------------------------------------------------------------

|Preto 800
|

|Nec-> 775,0|Stk-> 162,0|Enc-> 613,0|Est-> -55,0|Rec->
558,0|Csm-> 720,0|Exc-> 0,0|Sob-> 0,0|

|Nec-> 47,0|Stk-> 64,0|Enc-> -16,0|Est-> 46,0|Rec->
30,0|Csm-> 94,0|Exc-> 49,0|Sob-> 0,0|

|-----------------------------------------------------------------------------------------------------------------------|

|
|

|-----------------------------------------------------------------------------------------------------------------------|

|
|

|-----------------------------------------------------------------------------------------------------------------------|

|
|

|-----------------------------------------------------------------------------------------------------------------------|

|
|

|-----------------------------------------------------------------------------------------------------------------------|

|
|

|-----------------------------------------------------------------------------------------------------------------------|

|
|

-------------------------------------------------------------------------------------------------------------------------
 
N

NickHK

Pedro,
Why not use the capability of Word and insert a table .
Or do you need to use ASCII characters for some reason ?

NickHK
 
P

Pedro Leite

hi.

hmmm, lets say that my skills on "piloting" word from excel using vba are
not very deep to say the least.
i found the ascii approach simple and sufficient for my purpose. this report
is just a summary of orders to be printed on completion and filed together
with the original po. in the mean time, i fiddled a bit with tables but if i
can make the report neater with the ascii chars i would call it closed.

anyway, thank you for your suggestion that ill pursuit. if not for other
reason, to learn. otoh, if you know how to force those special characters,
it would be nice.

thank you in advance

Pedro Leite
-------------------------------------------------------------------------------------------------------
 
N

NickHK

Pedro,
You can record a macro in Word that will give the basis of the required
code. Running that from Excel generally mean adding a Word object variable
to beginning of statements.
Dim WordApp as Word.Application
Set WordApp = New Word.Application
WordApp.Documents.Add
ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=5, NumColumns:= _
3, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
wdAutoFitFixed

As for using text only costruction, again record a macro whilst you insert
some symbols. You should get something like :
Selection.InsertSymbol Font:="Courier New", CharacterNumber:=9484,
Unicode:=True
Selection.InsertSymbol Font:="Courier New", CharacterNumber:=9492,
Unicode:=True

But I must say, use Word's table feature instead of drawing it yourself.

NixkHK
 
P

Pedro Leite

good morning

thank you for your kind help.

Ill give it a shot at the table design.

Best Regards.

Pedro Leite
----------------------------------------------
 
P

Pedro Leite

well, you're right but i kinda do this for self training.

from excel i would have to build a new sheet with the layout and stuff. lets
just say that by doing this, i've learnt a few new things in office
automation.

thank you

Pedro Leite
-------------------------------------------------------------------------------
 
N

NickHK

Pedro,
Whilst it may involve some practice, trial/error, help etc, it is better to
use the tools that is suitable (Excel in case), rather than make life more
difficult for yourself in the long run.
You can (normally) record your required action in macro and although the
code is not the most efficient, you will get a good idea of what is needed.

Post back with another if (when) you need more help.

NickHK
 
Top