|
-
May 22nd, 2007, 02:10 AM
#1
Thread Starter
Member
[RESOLVED] Aligning Text in MS Word Thru VB6
Is There A Way On How To Align Text (ie. center) From MS Word Thru VB6 Code? I didnt used a table. is it still possible? A good code would be much appreciated... Thanks
-
May 23rd, 2007, 12:17 AM
#2
Re: Aligning Text in MS Word Thru VB6
I don't understand the question. You want to center-align text in a Word document? Can't you just record a macro to do that and then look at the recorded macro's VBA code?
-
May 23rd, 2007, 12:44 AM
#3
Thread Starter
Member
Re: Aligning Text in MS Word Thru VB6
I have here these sample codes:
------------------------------------------------
Dim oApp As Word.Application
Dim oDoc As Word.Document
Set oApp = New Word.Application
'Open either a blank new document or...
Set oDoc = oApp.Documents.Add
'open an exisiting document
'Set oDoc = oApp.Documents.Open("C:\Document1.doc")
oDoc.Activate
With oApp.Selection
'Move to the last line and add a new line.
.GoTo What:=wdGoToLine, Which:=wdGoToLast
.TypeParagraph
.Font.Size = 10
.Font.Name = "Arial"
.TypeText Text:="Sample Text"
End With
oApp.Visible = True
Set oDoc = Nothing
Set oApp = Nothing
------------------------------------------------
How will i align to center that text?
-
May 23rd, 2007, 01:33 AM
#4
Re: Aligning Text in MS Word Thru VB6
If you would be using the macro-recorder, you would get something like.
Code:
'the text you want to center has to be selected!
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
But you can't do that, since you are busy from double/tripple/quadruple psting the same question!
BTW: I won't post an answer to your other threat!
Note: Double-posting is considered to be bad manners!
You're welcome to rate this post!
If your problem is solved, please use the Mark thread as resolved button
Wait, I'm too old to hurry!
-
May 23rd, 2007, 01:48 AM
#5
Re: Aligning Text in MS Word Thru VB6
I am only online for a minute but I see you got the code from my FAQ. You have uncommented both methods of opening/creating a document.
If you already have the doc to open the dont create a new one.
Do like suggested and record a macro whenever you want to know how its done in Word.
http://vbforums.com/showthread.php?t=402032
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
May 23rd, 2007, 03:01 AM
#6
Thread Starter
Member
Re: Aligning Text in MS Word Thru VB6
RobDog888,
Im so sorry for all of that.. Im already confused of what to do with this. I've decided to bring out a clear case for you to help me.
This is a sample problem;
Suppose i have to put up a header on Word consisting of an image to the left and text on the center, like what common header have. Say,
!----------!..............Republic Of The Country
!->image<-!...................Province Of Prov
!----------!..................Cty Of Downtown
...Just like that
Can you pls make me a VB code for this with the output in MS Word? This will help me alot Mr. RobDog888. Hope you'll grant me with this one.
Thanks alot!!! More Power to You!!!
-
May 23rd, 2007, 11:10 AM
#7
Re: Aligning Text in MS Word Thru VB6
 Originally Posted by Ellis Dee
I don't understand the question. You want to center-align text in a Word document? Can't you just record a macro to do that and then look at the recorded macro's VBA code?
Did you try this approach?
Recording a macro and using the resulting code in VB6 has always worked for me.
-
May 27th, 2007, 08:19 PM
#8
Thread Starter
Member
Re: Aligning Text in MS Word Thru VB6
RobDog888 and Hack, first of all, i don't know in the first place on what to do with what you're sayin' bout that macro. 2nd, that docs will be created through VB Code on which variables from VB should be put to MS Word...
Hope you got what i'm saying, help me...
Thanks alot!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|