Changing Text Orientation/Direction In Table Cell - VBA Word Automation
Hi, I need to change the text direction/orientation to 90 degrees in a table cell in a Word document using automation. I know how to achieve this manually.
Right click on a table cell, select Text direction, in the window: select the orientation you want.
The same result I need to achieve through VBA automation. I am using Word 2003 & VB 6.
Could you please help me out in this regard ? Thanks in advance. Sisheer
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Selecting Text In A Word Table Cell
This has probably been answered many times before but I can't find the solution. I need to insert some text into a Word table and then change the font without affecting the text that was already in the cell. My code will look something like this:
Code:
Set oWord = CreateObject("Word.Application")
' Create a new Word document based on works_oder.dot template
oWord.application.Documents.Add App.Path & " emplatesworks_order.dot"
oWord.Visible = True
oWord.Activate
With oWord.ActiveDocument.tables(1) ' First table in Word template
.cell(1, 2).range.insertafter "Temp 0001"
.cell(2, 1).range.insertafter " " & cmbCustomers
.cell(2, 2).range.insertafter vbCrLf & txtDrawingNo
.cell(2, 4).range.insertafter vbCrLf & txtWorksOrderNo
.cell(3, 1).range.insertafter " " & txtCustOrderNo
.cell(4, 1).range.insertafter vbCrLf & txtRequiredBy
.cell(4, 2).range.insertafter vbCrLf & txtDescription
End With
I guess I need to select the text I've just added and then apply the font formatting I need, but I can't quite work out the syntax to select just the new text and exclude the original contents of the cell. Thanks!
Progress Bar Orientation && Direction?
The basic VB progress bar control seems to only 'progress' in one direction:
If the control is oriented horizontally the bars progress from left to right and if it's orientated vertically the bars progress from the bottom to the top. Question: how can I change the direction of the progress bars?
Thanks!
A "word" About Changing Page Orientation In Word When Using VB6
I recently wrote a subroutine package to allow me to generate Word documents on the fly. When using it, I came across a problem that drove me crazy for a while - I am posting this to save others the headache I had.
The problem was that occasionally the top, bottom and side margins went "screwy." Example: even though the top and bottom margins were set to 1 inch and .5 inches respectively, and the right and left margins were both set to .5 inches, when the document was generated, the right margin was 1 inch and the rest .5 inches. In most cases, it worked properly, but occasionally I got this strange result.
The issues is that if you are going to change the page orientation to landscape from portrait (or visa-versa), you need to do it BEFORE you change or set the margins. While this is probably not technically accurate, the following visualization explains what is happening:
Assume you have a portrait oriented document. When you set the top, bottom, right and left margins (or any combo thereof), everything is okay. If you then change the document orientation to landscape, its almost as if the page its rotated 90 degrees (rather than shortened and widened). The two sides rotate around and become the top and bottom and the original top and bottom have rotated to become the sides. The margins STAY attached to their original top and bottom (which are now sides) and boths sides (which are now the top and bottom) after the rotation - the result is you get "screwy" margins.
Because of the combinations of changing margins and orientations in different orders, it took me a while to figure it out. Simply changing the orientation first fixes the issue.
I hope this makes sense and helps ....
Jim
Word 97: How To Insert A Table Into An Existing Table Cell
Does anyone know how I can insert a New Table into a cell of another table?
In Word 2000, I can issue the following code when I am within a cell of a table and the table gets inserted correctly:
Dim rRange As Range, myTable As Table
With Selection
Set rRange = .Range
Set myTable = rRange.Tables.Add(Range:=.Range, NumRows:=2, NumColumns:=4)
End With
However, in Word97, I am not able to do this. I get an error telling me that a table already exists. Has anyone had any success with being able to insert a new table into a cell of an existing table without doing a lot of cell/row inserts and cell merges?
How To Insert Table Into A Cell Of Another Table Using Word Object
hi friends,
i have inserted a table into word do using word object through VB
wddoc.tables.add selection.range, 2, 4
now i wanto to insert a table into the cell of the table created.
can u help me how to do that
i have tried like this
wddoc.tables(1).cell(1,1).range.tables.add selection.range,2,4
but i am getting an error saying that table already exists in that location,
PLEASE HELP ME OUT!!!!!
thanx
How To Insert Table Into A Table Cell Of Word
hi friends,
i am creating a word doc from VB and then i want to insert tables into it. i am inserting table in the following manner
wdapp.ActiveDocument.Tables.Add selection.range, 4, 1
wdapp.ActiveDocument.Tables.Add selection.range, 2, 2
but it is able to create the first table but not the second table. it is giving a error message saying that table already present in the location.
can u tell me how to insert 2 or more tables into the word doc through coding
thanx,
How To Insert Table Into A Table Cell Of Word
hi friends
i want to add a table inside a table cell, i am using the following code to achieve this, but i am getting and error saying that the table is already located in the location. i think there is some problem with the range.
wdapp.ActiveDocument.Tables(2).Cell(2, 1).Range.Tables.Add wdapp.ActiveDocument.Tables(2).Cell(2, 1).Range, 2, 1
thanx,
How To Insert Table Into A Table Cell Of Word
hi friends
i want to add a table inside a table cell, i am using the following code to achieve this, but i am getting and error saying that the table is already located in the location. i think there is some problem with the range.
set drange=wdapp.ActiveDocument.Tables(2).Cell(2, 1).Range
wdapp.ActiveDocument.Tables(2).Cell(2, 1).Range.Tables.Add drange, 2, 1
i am using word 8.0 dll i.e word 97
thanx,
------------------------------------------------
Good Friend...
------------------------------------------------
Table Width Issue (Word Automation From Access)
Greetings!
Recently, I've been playing with Word automation, trying to create a tool, which would generate Word document.
At the moment, I'm stuck with table widths...
As you can see from the attachment, the third table is wider than first two, while all three of them have to have width of all available space.
I use Tables(x).PreferredWidthType = 2 (wdPreferredWidthPercent) and Tables(x).PreferredWidth = 100 (100%) right after I add a table in the code, but after, if I check the tables in the generated document, first two have width of 98.2%... (?!)
Can anyone tell why does this happen?
I'm using Access and Word 2007.
-----------------------------------------------------------------
Making mistakes is one of the ways of improvement.
GL and HF
Edited by - un5killed on 6/1/2007 2:03:28 AM
How To Get The Aligment Of A Table Cell In Word
Hi,
I have written a macro, which traverses the table of a word document and outputs the text in particular format to a text file. While doing so i need to retain the look of the table and for which i need to know the aligment of the cells in the table whether centered, left or right aligned.
Is there any means by which this be achieved?
Thanks
Niranjan
Getting Cell Alignment Of A Table In Word
Hi,
I have written a macro, which traverses the table of a word document and outputs the text in particular format to a text file. While doing so i need to retain the look of the table and for which i need to know the aligment of the cells in the table whether centered, left or right aligned.
Is there any means by which this be achieved?
Thanks
Niranjan
Copy A Cell To A Word Table
This type of topic has been going around a lot lately. I have been searching the forum, but am still lost on the subject. I have taught myself VBA in Excel and feel very comfortable with that. However, I know need to copy a cell(s) to a word table and am having a great deal of trouble with this. Can't seem to get it through my thick skull I guess. BTW have done a google search as well. Anyway, here is the story...
I have a sales worksheet that is filed out when an admin person answers the phone. The worksheet contains basic information...name address reason for call and the like. If the sale goes through I need the name and address copied into word for the contract (a lot double typing that can be typed once...push a button and presto; all of the fields in word are copied over). Anyway, if someone could spell this out for me, it would be a huge help. Thanks for the help in advance.
-JD
Selecting A Whole Cell In A Word Table
Hi there.
I'm struggeling with the following:
I have a Word document with 2 columns. It contains 100 rows, which gives a total of 200 cells.
One of the rows are looking something like this:
_______________________________
|________________|______________|
In my code, I'm able to locate/find the correct row I want to do my selection.
I have a bookmark (called "Labelx" where x is the number of the cell) in every cell.
I'm able to select the first cell (that is the cell to the left), and I'm also able to put my cursor in the next cell (the one to the right).
The big challenge is to "mark"/highlight/select the cell to the right.
The purpose is that I want to select this cell and delete all the contents in it.
Can anyone give me some direction?
So far I have this code:
BookM = "Label" & (i+2) 'This selects the bookmark in the row below the row I want to delete
ActiveDocument.Bookmarks(BookM).Range.Select
Selection.MoveUp Unit:wdLine, Count:=1
Selection.EndKey Unit:=wdStory, Extend:= wdExtend
Selection.Delete
This code, selects all the remaining rows in the documents and deletes them. This is my purpose.
But I also want the code to delete the cell to the right in the last row AFTER deleting the remaining rows.
Hope that my explaination is good enough, if not - give me a hint and I will try to improve.....
Colspan Of Table Cell In MS Word
Hi,
I'm wondering how my Macro can determine if a table cell in MS Word spans multiple columns and if so how many.
thanks in advance
MS WORD XP Table Cell Sizes
Hey there
I'm writing an application that reads data from a mutlidimensional array into tables in a word document. I've got it up and running with MS Word 2000, but with MS Word XP, some of the cell sizes on the tables are wrong.
anyone else run into something like this ?!?
oh btw. its not really VBA its in VB (using WORD10 library).
thanks in advance.
Word Creation - Table Cell Alignment
Hello everybody,
I am trying to create an MS word document automatically through VB. In that document, there should be a table. The table should have 4 columns. The data in the last two columns needs to be right aligned. I could create table and fill it with data from table. But I am not able to right align contents of 3rd and 4th columns of the table. Could anybody please help me ?
I am attaching the code I wrote(A part of it I got from net)
Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oTable As Word.Table
Dim oTitle As Object
Dim iCount As Integer
Dim intYCount As Integer
Dim intXCount As Integer
Dim bCreateOrGot As Boolean
Dim intXMax As Integer
Dim intYMax As Integer
Dim strTitle As String
strTitle = "My word document"
Dim rstTable As ADODB.Recordset
Dim qryTable As String
qryTable = "SELECT artisteid,productionname, grossamount, (grossamount*17.5/100) as vat FROM artistevouchers"
Set rstTable = New ADODB.Recordset
rstTable.Open qryTable, cnnArtists, adOpenDynamic
intYMax = rstTable.Fields.Count
rstTable.MoveLast
intXMax = rstTable.RecordCount + 1
rstTable.MoveFirst
On Error Resume Next ' Defer error trapping.
bCreateOrGot = True
Set oWord = New Word.Application
bCreateOrGot = False
err.Clear ' Clear Err object in case error occurred.
If bCreateOrGot = False Then
With oWord
.Visible = True
.Documents.Add ("c:project
eceipt.doc")
End With
End If
Set oDoc = oWord.ActiveDocument
On Error GoTo 0
If bCreateOrGot = True Then
With oDoc.Application.Selection
.InsertBefore Text:=strTitle & vbCrLf
With .Find
.Text = "^l"
With .Replacement
.Text = ""
End With
.Execute Replace:=wdReplaceAll
End With
With .Font
.Bold = True
.Name = "Arial"
.Size = 8
End With
.MoveRight Unit:=wdCharacter, Count:=1
.InsertAfter Text:=vbCrLf
End With
Set oTable = oDoc.Tables.Add(Range:=Selection.Range, NUMROWS:=intXMax, NumColumns:=intYMax)
Else
With oDoc.Application.Selection
.InsertBefore Text:=vbCrLf & strTitle
Dim iloop As Integer
With .Find
.Text = "^l"
With .Replacement
.Text = ""
End With
.Execute Replace:=wdReplaceAll
End With
With .Font
.Bold = True
.Name = "Arial"
.Size = 8
End With
.MoveRight Unit:=wdCharacter, Count:=1
End With
Set oTable = oDoc.Tables.Add(Range:=oDoc.Range(Start:=17, End:=17), NUMROWS:=intXMax + 1, NumColumns:=intYMax)
End If
For intYCount = 0 To intYMax - 1 'Add headings
With oTable.Cell(Row:=1, Column:=intYCount + 1).Range
.InsertAfter Text:=rstTable.Fields(intYCount).Name
End With
Next
intXCount = 2
Dim f_total_gross_amount As Currency
Dim f_total_vat As Currency
f_total_gross_amount = 0
f_total_vat = 0
Do Until rstTable.EOF
oTable.Rows.Add
For intYCount = 0 To intYMax - 1
With oTable.Cell(Row:=intXCount, Column:=intYCount + 1).Range
If Not IsNull(rstTable.Fields(intYCount).Value) Then
Dim str_value As String
If (intYCount = 2) Then
f_total_gross_amount = f_total_gross_amount + rstTable.Fields(intYCount).Value
End If
If (intYCount = 3) Then
f_total_vat = f_total_vat + rstTable.Fields(intYCount).Value
End If
If (intYCount = 2 Or intYCount = 3) Then
str_value = String(12 - Len(CStr(rstTable.Fields(intYCount).Value)), Chr(32)) & Format(CStr(rstTable.Fields(intYCount).Value), "#0.00")
Else
str_value = CStr(rstTable.Fields(intYCount).Value)
End If
.InsertAfter Text:=str_value
Else
.InsertAfter Text:=""
End If
End With
Next intYCount
intXCount = intXCount + 1
rstTable.MoveNext
Loop
oTable.Rows.Add
With oTable.Cell(Row:=intXCount, Column:=2).Range
.InsertAfter Text:="Total"
End With
With oTable.Cell(Row:=intXCount, Column:=3).Range
.InsertAfter Text:=Format(CStr(f_total_gross_amount), "##########0.00")
End With
With oTable.Cell(Row:=intXCount, Column:=4).Range
.InsertAfter Text:=Format(CStr(f_total_vat), "##########0.00")
End With
oTable.AutoFormat Format:=wdTableFormatGrid8, ApplyBorders:=True, ApplyFont:=True, ApplyColor:=True, ApplyHeadingRows:=True
oTable.Select
With oDoc.Application.Selection
.Collapse Direction:=wdCollapseStart
.InsertParagraph
.Collapse Direction:=wdCollapseStart
End With
Set oTable = Nothing
Set oDoc = Nothing
Set oWord = Nothing
Create Textbox In Every Cell From A Word Table
Hallo everyone,
I have a table wich contains texts and images in every cell, I would like to select everything is in a cell and put it in a textBox,so I will have a textbox for every cell.
I try this
Count = 1
For currRow = 1 To (Selection.Tables(1).rows.Count)
For currCol = 1 To Selection.Tables(1).Columns.Count
Selection.GoTo What:=wdGoToBookmark, Name:="Bookmark_" & Count
Selection.Tables(1).Cell(currRow, currCol).Select
Selection.CreateTextbox
Selection.ShapeRange.Line.DashStyle = msoLineDash
Count = Count + 1
Next currCol
Next currRow
But I have an error anyone could help me?
Thany you.
Adelin
Word 97 - Bookmarks/table Cell Refs
Hi
I know how to create a simple bookmark in Word using VB, but is there a way to tell it to find a table cell ref and create the bookmark?
Thanks
Pendle
How To Retrive An Image From A Table Cell Of Word Doc
hi friends,
i have inserted an image using the following code-
wdapp.ActiveDocument.Range.InlineShapes.AddPicture("c:image1.gif")
how should i retrieve this image into a picture box without losing the quality of the image,
i have tried with the
range.copy
picture1.picture=clipboard.getdata
i got the image but the image quality is very poor!!
HELP ME OUT PLEAAZZZZZZ..
THANX.
How To Retrive An Image From A Table Cell Of Word Doc
hi friends,
i have inserted an image using the following code-
wdapp.ActiveDocument.Range.InlineShapes.AddPicture("c:image1.gif")
how should i retrieve this image into a picture box without losing the quality of the image,
i have tried with the
range.copy
picture1.picture=clipboard.getdata
i got the image but the image quality is very poor!!
HELP ME OUT PLEAAZZZZZZ..
THANX.
Word Table: Mixed Cell Widths ?
Please, help in this situation.
My Word-table has some splitted cells in a header.
I try to insert data to lower cells. But I have the message "Cannot access individual columns in this collection because the table has mixed cell widths. How to work with a table of such kind?
Thanks.
Vba Changing Cell Text
Using Excel 2000
Problem:
I want to change the text/value of a cell programmatically.
For testing purposes, i've used the following formula.
=IF(Q40>AH40,"YES","NO")
But instead of returning a "YES" or a "NO" to the current cell containing the formula, i'd like to change the value of a different cell (increment the current value by 1).
Issue:
Using a VBA function is not working, it reaches the code line that populates the cell with the new incremented value, then nothing. It neither updates the cell nor finishes the function.
Code:
'Neither of the following will work
'lngStock1 is a long variable = to the incremented value
Worksheets("List").Cells(1, "B").Value = lngStock1
Worksheets("List").Cells(1, "B").Formula = "=" & lngStock1 & "+1"
Worksheets("List").Cells(1, "B").Value = "4"
'Placing that same code inside a button click does work only
'if the user clicks the button however
Private Sub cmdTWH_Click()
Worksheets("List").Cells(lngStock1, "L").Formula = "=" & lngStock1 & "+1"
Worksheets("List").Cells(lngStock2, "L").Formula = "=" & lngStock2 & "+1"
End Sub
Any help would be appreciated because my boss is getting impatient!!
~Tony Huss
MSWORD Making One Word Bold In A Table Cell.
Hi
I am creating a report in word using tables in VB6.
One of the cells contains a surname and then two foren
ames for married
partners. I need to have the surname in bold and the
forenames as
normal.
When I do this I can make the whole cell bold or n
ormal. Can anybody
help?
Regards
Peter
Important Note: This E-Mail is confidential, it must not
be read,
copied, disclosed or used by any person other than the
above
named addressees. Unauthorised use, disclosure or copying is
strictly prohibited and may be unlawful. Eurostar (U.K.) L
imited
and Eurostar Group Limited disclaim any liability for any
action
taken in reliance on the content of this E-Mail. The c
omments
or statements expressed in this E-Mail are not necessarily
those
of Eurostar (U.K.) Limited, Eurostar Group Limited or any
subsidiaries or affiliates of either company.
Eurostar (U.K.) Ltd. Registered Office: Eurostar House, Wate
rloo
Station, London, SE1 8SE, Registered in England No. 246200
1
VAT No. GB 657 719 590
Eurostar Group Ltd. Registered office: Eurostar House, Water
loo
Station, London, SE1 8SE, Registered in England No. 379464
2
VAT No. GB 739 974 173
This email has been scanned for all viruses by the Mes
sageLabs Email
Security System on behalf of Eurostar. For more informatio
n on a proactive email security service working around t
he clock, around the globe, visit http://www.messagelabs.com
Change Font Bold Of A Cell In A Table In Word From VB
I've used some code from johnwm in thread222-589129 some time ago to help me make the table. From that I've figured out how to change the "header row" background color. Now I'm trying to change the "header row" font to bold but I'm having diffieculty. Can someone help. Here is the how I change the color of row 1 for each column.
CODE'This will change the color of the header row in the table
With MyRange.Tables.ITEM(1)
For g = 1 To .Columns.Count
' .Cell(1, g).Select.Font.Bold = wdToggle
.Cell(1, g).Shading.BackgroundPatternColor = wdColorYellow
Next g
End With
Problem Accessing A Merged Cell In A Word Table Using MACRO
Hi ,
I am writing a macro which converts a MS WORD table into particular format. I need to retain the structure of the table while doing so.
The main problem is that if a row consists of a merged cell then there is no means to identify this at runtime. If a merged cell has occured in the input table i need to place a identifier for the same in the output....
Could anyone please let me know how can i achive this ?
Thanks
Table Cell Text Contains Box?
Hi
When I read table cell content into a variable, it contains cell text + some unkown character which is shown as small box.
How to filter that unwanted character from cell text content?
natrajv
Changing Direction
I am making a snake-like game for my programming class and i have not a clue in the world on how to change the direction of the snake with bitblt. any help is much appreciated. thanks
Changing Tab Direction
What is the easiest way to change the cell that is activated on a worksheet to go down (row) to the next unprotected cell, instead of to the right (column)....and then once all of the unprotected cells in the column are accessed, to go to the next unprotected cell in the adjoining right column.
Yeesh that sounds confusing!!!
Simply stated, once I press TAB, I want to go Down, not Right.
Changing Direction
Hello!!!
Is there a way to make the button of the ComboBox appear in the left side of the control, without using the RightToLeft property?
The problem is that I want to write an ActiveX that is based on the ComboBox, but I can't let the user use the RightToLeft property because it's read-only at run-time (of the control). Maybe there's an API function that does this.
I hope you understand my question. If so, please answer!
Thanks!!!
Problem Changing Cell Text Color In Flex Grid
I am having a weird problem.
I need to change the cells forecolor for an entire column on a user click but am not having luck.
My code is as such:
MSFNums.Col = 5
For i = 1 To MSFNums.Rows
If MSFNums.Text > 0 Then
MSFNums.CellForeColor = vbGreen
ElseIf MSFNums.Text < 0 Then
MSFNums.CellForeColor = vbRed
Else
MSFNums.CellForeColor = vbBlack
End If
This should change the color for about half of them but does not. It goes to the command but does not change the colors to black, red, or green.
I tried simply making a test button with the code:
MSFNums.Col = 5
MSFNums.CellForeColor = vbGreen
I changed the row and color and this worked. Why does it not work in the loop?? Why does the cellforecolor not change in the foreloop?
In flexgrid you give the row and column and the command effects that row. My test button simulates part of the loop and works...
Changing Direction Of Something In Movement...
I have a button in movment from left to right (starting on top left side) and I want to move it around the borders of the form. How do I code that when the button reach the end of the current border it change its direction?
Changing Direction Of An Image!!!
Hi, I started making a program in VB 5 in which I make an image of a car move around the form, when I turn it left or right it goes in that direction, but the only thing is that the image of the car doesn't change the same way and it looks silly. Can someone please HELP!!!
WORD AUTOMATION && BOLD TEXT
You will mock me for years!.. but I could not set a row of a word table in BOLD style!! I have to turn a bi-dimensional array in a word table... and when I met the "§B§" string in a cell, set that row to BOLD.
rTot: Number of rows of the array.
cTot: Number of columns of the array.
Wtab: Word table
mycell: string
matrix: bi-dimensional array of strings
------------------------------------------------------------------------
For R = 1 To rTot
RowBold = False
For c = 1 To cTot
mycell = CStr(Matrix(R, C))
If InStr(mycell, "§B§") <> 0 Then
mycell = Left(mycell, Len(mycell) - 3)
RowBold = True
End If
Wtab.cell(R, c).Range.Text = mycell
If IsNumeric(mycell) Then Wtab.cell(R, c).Range.ParagraphFormat.Alignment = 2
Next
If RowBold = True Then
Wtab.Rows.item(R).Range.Font.Bold = True
End If
Next
-------------------------------------------------------
The Wtab.Rows.item(R).Range.Font.Bold = True statement should work... Or, at least, this is what I read in several forums...
HELP!!!
Word Automation && Bold Text [HELP!]
You will mock me for years!.. but I could not set a row of a word table in BOLD style!! I have to turn a bi-dimensional array in a word table... and when I met the "§B§" string in a cell, set that row to BOLD.
rTot: Number of rows of the array.
cTot: Number of columns of the array.
Wtab: Word table
mycell: string
matrix: bi-dimensional array of strings
------------------------------------------------------------------------
For R = 1 To rTot
RowBold = False
For c = 1 To cTot
mycell = CStr(Matrix(R, C))
If InStr(mycell, "§B§") <> 0 Then
mycell = Left(mycell, Len(mycell) - 3)
RowBold = True
End If
Wtab.cell(R, c).Range.Text = mycell
If IsNumeric(mycell) Then Wtab.cell(R, c).Range.ParagraphFormat.Alignment = 2
Next
If RowBold = True Then
Wtab.Rows.item(R).Range.Font.Bold = True
End If
Next
-------------------------------------------------------
The Wtab.Rows.item(R).Range.Font.Bold = True statement should work... Or, at least, this is what I read in several forums...
HELP!!!
Changing Orientation
Hi there,
Does anyone know how to change the orientation of a word document. I am using VB6 so I am unable to use code like
active document.pagesetup
Is there some way of changing the default settings of word so that all documents open in lanscape?
A present I simply using
Open "MyFile.doc" For Output As #1
Is there some other way of opening up a new word document that can be named and have its orientation changed by code?
Can this code run on VB6 without sp5?
Thanks.
Garth.
Etracting Plain Text From Word Via Automation
Is there a nice way to do this Without saving the document to disk? I want to download a Word file 'blob', decode it with the Word object lib, grab all of the existing text and index it. (Basically an on-the-fly Word to plain text converter)
Thanks
Andrew
Word Automation - How To Insert Text And Set To Bold?
I'm dynamically creating Word docs in my VB6 app.
I'm using Word 2002 (v10).
In most cases I find and replace a marker field [keyName] in the template with some content from my app.
This works fine and allows the user to set the style of the text by setting the marker field (it's replaced in the same style).
I now have a piece of content that needs to be formatted by the code.
Basically I'd like:
Header 1
Para
Header 2
Para
Para
Para
Header 3
Para
Para
I've tried setting the Font to Bold but it doesn't work as I anticipate
In fact I get this!
Header 1
Para
Header 2
Para
Para
Para
Header 3
Para
Para
Here's the code:
Code:
With WordApp
' Find the insertion point
With .Selection.Find
.Forward = True
.ClearFormatting
.MatchWholeWord = True
.MatchCase = False
.Wrap = wdFindContinue
.Text = insertAfter ' The marker in the template
found = .Execute
End With
If Not found Then Exit Sub
With .Selection
' Collapse the selection and move to the end
.Collapse wdCollapseEnd
' Get the data...
Dim com As ADODB.Command
Set com = New ADODB.Command
With com
.ActiveConnection = MDImain.db.cnn
.CommandType = adCmdStoredProc
.CommandText = "qryQuoteOptionSectionsDetails " & optionID & ", " & quoteID
Set rsSections = .Execute
End With
optionTotal = 0
Do While Not rsSections.EOF
' Section description should be highlighted
fieldValue = rsSections!description & vbCr
.Font.Bold = True
.insertAfter fieldValue
' Reset font
.Font.Bold = False
' Get more data...this should not be bold
fieldValue = "<more data with carriage returns>"
.insertAfter fieldValue & vbCr
rsSections.MoveNext
Loop
rsSections.Close
End With
End With
I've tried everything I can think of but I'm just guessing now!
Any ideas!?
Mac
Edited by - AbbydonKrafts on 10/15/2006 3:02:39 PM
Printer Orientation Not Changing
I've browsed through the forum and read the posts on printing, did help. I can get the file to print without a problem. The printer dialog pops up and everything, but my problem is that whether i change the orienation in the printer dialog or hard code the orientaion change, its not accepted.
It won't print landscape, which is what is needed.
Here the code so far..
CommonDialog1.ShowPrinter
' get user-values
BeginPage = CommonDialog1.FromPage
EndPage = CommonDialog1.ToPage
NumCopies = CommonDialog1.Copies
Orientation = CommonDialog1.Orientation
strFileName = cboAwards.Text
strPath = frmMain.GetDir
strName = strPath & "" & strFileName
Orientation = 2
'Printer = ShellExecute(Me.hwnd, "PRINT", strName, "", "", -1)
Dim PrintIt As Long
printer.Orientation = 2
PrintIt = ShellExecute(Me.hwnd, "PRINT", strName & ".txt", "", "", -1)
printer.EndDoc
Any suggestions?
Changing The Orientation Of A Report
I need to change the orientation of a report created using the report editor in visual basic 6. Im sure that there has to be an easy way of doing this.
Any help would be greatly appreciated.
Thanx in advance
Jason
VB Automation For Formatting Text Of Exisitng Word Document
Hi,
Here is my problem description:
I have a chunk of text in a word document. Every word here is marked with a custom bookmark and the entire text chunk is marked by a start / end bookmark.The text is formatted in a certain way, say for eg: every sentence begins at a newline.
Based on a hotkey, or an event, I want to go into the word document, read this chunk and manipulate the formatting.
Would anyone know how this could be done? is it even possible?? This is urgent and any help would be appreciated. U could email me directly at jagdsingh@yahoo.com
thanks a lot.
Common Dialog Changing Orientation?
I'm trying to use the Common dialog control to change my default printer and the print orientation of selected printer. Easy enough... but doesn't seem to work on my NT 4.0 box? The printer.DeviceName changes but orientation will not change?
Here is the code. Am i missing something?
=========================================================
CommonDialog1.PrinterDefault = True
CommonDialog1.ShowPrinter
MsgBox Printer.DeviceName & " : " & Printer.Orientation
=========================================================
Changing Print Orientation Problems HELP
I am in need of some assistance. I have an application built for printing BMP and JPG images.
I need to be able to change the printers page orientation on the fly programmatically.
I have the following code written, but the orientation does not change:
Set Printer = Printers(0)
Printer.PrintQuality = 600
Printer.Orientation = 1
Printer.PaintPicture LoadPicture(ImageLocation + "PrintTemp.bmp"), 1, 1, 5760, 4320
Printer.PaintPicture LoadPicture(ImageLocation + "PrintTemp.bmp"), 1, 4320, 5760, 4320
Printer.EndDoc
The above should be placing 2 images on a 4 x 6 sheet of paper in Portrait mode one image at the top then the second image under it.
The statement, "Printer.Orientation = 1" should switch the orientation to Portrait. I have also tried the explicit call:
Printer.Orientation = vbPRORPortrait.
It doesn't work either.
It prints the images, but in Landscape paper mode...
Any suggestions?
Thanks
Don
Changing Printer Orientation At Runtime
Hi,
I have a specific problem with printer settings. I have developed some reports using VB6.0 Data Reports. When the printer orientation setting is 'Portrait', my reports looks fine. However, when the windows printer setting is changed to 'Landscape', the report print preview shows disturbance in the placement of fields.
To solve this problem, I tried to change the setting at runtime by using 'Printer.Orientation=VBProrLandscape', before the report is displayed. But this did not worked out. Even I tried an api 'Escape' to set the printer setting to 'Portrait' but in vain.
I would appreciate, if you could give me solution to this problem.
Waiting for an early reply.
Bye
PCS
Changing Report Orientation ; VB6 And Crystal Reports
Hello,
I am using Crystal Report Control (crystl32.ocx) in my VB application. I am able to change printers, but cannot change orientation (shifting from landscape to portrait and vice-versa). How can I change the orientation at runtime? Below is the sample code I have so far.
Please help!
Thanks!
=========================================
Private Sub Command1_Click()
Dim X As Printer
Me.CrystalReport1.ReportFileName = App.Path & "AlertTest.rpt"
For Each X In Printers
If X.DeviceName = "\SCGI_RASHP LaserJet 2200 Series PCL 6" Then
Me.CrystalReport1.PrinterDriver = X.DriverName
Me.CrystalReport1.PrinterName = X.DeviceName
Me.CrystalReport1.PrinterPort = X.Port
Exit For
End If
Next
Me.CrystalReport1.Destination = crptToPrinter
Me.CrystalReport1.Action = 1
Set X = Nothing
End Sub
Changing Print Orientation ; VB6 And Crystal Reports
Hello,
I am using Crystal Report Control (crystl32.ocx) in my VB application. I am able to change printers, but cannot change orientation (shifting from landscape to portrait and vice-versa). How can I change the orientation at runtime? Below is the sample code I have so far.
Please help!
Thanks!
Code:
Private Sub Command1_Click()
Dim X As Printer
Me.CrystalReport1.ReportFileName = App.Path & "AlertTest.rpt"
For Each X In Printers
If X.DeviceName = "\SCGI_RASHP LaserJet 2200 Series PCL 6" Then
Me.CrystalReport1.PrinterDriver = X.DriverName
Me.CrystalReport1.PrinterName = X.DeviceName
Me.CrystalReport1.PrinterPort = X.Port
Exit For
End If
Next
Me.CrystalReport1.Destination = crptToPrinter
Me.CrystalReport1.Action = 1
Set X = Nothing
End Sub
|