msvisual.com Forum Index
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

how to call this function

 
Post new topic   Reply to topic    msvisual.com Forum Index -> OLE Automation
Author Message
rajkumar_rv



Joined: 04 Oct 2007
Posts: 1

PostPosted: Tue May 29, 2007 3:23 am    Post subject: how to call this function Reply with quote

Hi all,

Can you tell me please what is the process to use this function.

1. how to call this function :- createApdxBDoc(outputArray() As CApdxB)

I have pasted this code into Vb project at run time it show user defined
error at "createApdxBDoc(outputArray() As CApdxB)" this point.

the code below attached.

Thanx
RAJ


Private Sub createApdxBDoc(outputArray() As CApdxB)
Dim objWord As Word.Application
Dim objDoc As Word.Document

Dim row As Integer
row = 5

'open word
Set objWord = New Word.Application
'add the document
Set objDoc = objWord.Documents.Add
'make it the current document
objDoc.Activate

'make it visible
objWord.Visible = True

'set page orientation to landscape (affects the table size)
objDoc.PageSetup.Orientation = wdOrientLandscape
objDoc.ActiveWindow.View.Type = wdNormalView

'set the doc range
objDoc.Range.Delete
Set rng = objDoc.Range

'iterate through the output array and add contents to document
For row = 1 To UBound(outputArray) - 1
'process page header
If Val(outputArray(row).sType) >= 1 And Val(outputArray(row).sType) <= 8 Then
processPageHeader outputArray, row, objDoc
Else
'process table data
processTable outputArray, row, objDoc
End If 'table or subhead

'Debug.Print "createTable loop row = " & row
Next row

End Sub
''''------------------------------------------------------------------

''''This subroutine inserts a page break and prints a page header. The only
thing to emphasize here is to remember to reset any font properties, which
has to be done after a paragraph break.

''''---------------------------------------------------------------------
Private Sub processPageHeader(outputArray() As CApdxB, row As Integer, _
objDoc As Word.Document)
'Private Sub processPageHeader(row As Integer, _
objDoc As Word.Document)
'table of heading data
Dim headingsTbl(Cool As String
headingsTbl(1) = "B-1. Standards Compliance (Level 1)"
headingsTbl(2) = "B-2. Network Compliance (Level 2)"
headingsTbl(3) = "B-3. Platform Compliance (Level 3)"
headingsTbl(4) = "B-4. Bootstrap Compliance (Level 4)"
headingsTbl(5) = "B-5. Minimal DII Compliance (Level 5)"
headingsTbl(6) = "B-6. Intermediate DII Compliance (Level 6)"
headingsTbl(7) = "B-7. Interoperable Compliance (Level 7)"
headingsTbl(Cool = "B-8. Full DII Compliance (Level Cool"

'first page doesn't need a page break
If Val(outputArray(row).sType) > 1 Then
objDoc.ActiveWindow.Selection.InsertBreak wdPageBreak
End If

objDoc.ActiveWindow.Selection.Font.Bold = True
objDoc.ActiveWindow.Selection.Font.Size = 16
objDoc.ActiveWindow.Selection.TypeText Text:= _
headingsTbl(Val(Left$(outputArray(row).sType, 1)))
objDoc.ActiveWindow.Selection.TypeParagraph
objDoc.ActiveWindow.Selection.TypeParagraph
objDoc.ActiveWindow.Selection.Font.Bold = False
objDoc.ActiveWindow.Selection.Font.Size = 10
End Sub
'----------------------------------------------------------------
'
'The TypeParagraph command inserts a blank line and separates the selection
so changes to
'the font properties wont affect already printed text. If you change font
without an
'intervening paragraph, the changes affect the text that was just printed
'
'The following subroutine took the longest to work out. It creates a table
with four columns
'and an arbitrary number of rows. At irregular intervals, a table row will
'contain a subhead rather than table data. The subheads need to be centered
in a shaded box.
'The routine creates the table and sets the width of the columns, then it
fills the table cell-by-cell, moving to the right by one cell for each data
item. Of course, Word obligingly creates a new table row when the row above
is filled. Once the table is completely filled, the routine goes back to the
top of the table and scans down looking for a subhead entry. When it finds
one, it selects the entire row, merges the cells, centers the text, and sets
the font and background texture.
'
'-------------------------------------------------------------
'Private Sub processTable(row As Integer, _
'objDoc As Word.Document)
Private Sub processTable(outputArray() As CApdxB, row As Integer, _
objDoc As Word.Document)
Dim rowCount As Integer
Dim colCount As Integer
Dim ndx As Integer
Dim table As Word.table

'build the table
rowCount = 1
colCount = 4
Set table = objDoc.Tables.Add(objDoc.ActiveWindow.Selection.Range, _
rowCount, colCount)

table.Columns(1).Width = 45
table.Columns(2).Width = 45
table.Columns(3).Width = 280
table.Columns(4).Width = 280

'fill the cells
rowCount = 0
ndx = row
While outputArray(ndx).sType > "8" 'page headers are "1" thru "8"
objDoc.ActiveWindow.Selection.TypeText Text:=outputArray(ndx).sCompliance
objDoc.ActiveWindow.Selection.MoveRight Unit:=wdCell
'-------------------------------------------------------
'MoveRight tabs to the next cell.

objDoc.ActiveWindow.Selection.TypeText Text:=outputArray(ndx).sIndex
objDoc.ActiveWindow.Selection.MoveRight Unit:=wdCell
objDoc.ActiveWindow.Selection.TypeText Text:=outputArray(ndx).sText
objDoc.ActiveWindow.Selection.MoveRight Unit:=wdCell
objDoc.ActiveWindow.Selection.TypeText Text:=outputArray(ndx).sComments
objDoc.ActiveWindow.Selection.MoveRight Unit:=wdCell
ndx = ndx + 1
rowCount = rowCount + 1
Wend

'the last line of the table is blank; so delete it
objDoc.ActiveWindow.Selection.Cells.Delete ShiftCells:=wdDeleteCellsEntireRow

'move the selection back to the start of the table
objDoc.ActiveWindow.Selection.MoveUp Unit:=wdLine, Count:=rowCount
'-------------------------------------------------------------------
'Note: you have to still be in the table for the MoveUp to work right.
'-------------------------------------------------------------------
'find each of the subheaders and format that line
For ndx = row To row + rowCount
If outputArray(ndx).sType = "S" Then
'Debug.Print "Subheader for " & outputArray(ndx).sText

objDoc.ActiveWindow.Selection.EndKey Unit:=wdLine, Extend:=wdExtend
objDoc.ActiveWindow.Selection.MoveRight Unit:=wdCharacter, Count:=3,
Extend:=wdExtend
objDoc.ActiveWindow.Selection.Cells.Merge
'------------------------------------------------------------------
'The three lines above select the entire row and merge the cells
'------------------------------------------------------------------
objDoc.ActiveWindow.Selection.Font.Size = 14
objDoc.ActiveWindow.Selection.Font.Bold = wdToggle
objDoc.ActiveWindow.Selection.ParagraphFormat.Alig nment =
wdAlignParagraphCenter
With objDoc.ActiveWindow.Selection.Cells
With .Shading
..Texture = wdTexture10Percent
End With
End With
'---------------------------------------------------------------------
'The With .Shading construct above applies the background pattern to the
selected line
'---------------------------------------------------------------------
objDoc.ActiveWindow.Selection.MoveRight Unit:=wdCell, Count:=2
'---------------------------------------------------------------------
'The third cell contained the text when I merged the row, so moving right
two cells moves from cell 3 to cell 4 and then to the first cell of the next
line.
'---------------------------------------------------------------------
Else
objDoc.ActiveWindow.Selection.MoveDown Unit:=wdLine, Count:=1
End If

Next ndx

'move out of the table
objDoc.ActiveWindow.Selection.MoveDown Unit:=wdLine, Count:=1
objDoc.ActiveWindow.Selection.TypeParagraph
'------------------------------------------------------------------
'Lastly, move down out of the table and insert a blank line before starting
the next page.
'-------------------------------------------------------------------
row = row + rowCount - 1

End Sub

Archived from group: microsoft>public>vb>ole>automation
Back to top
View user's profile Send private message
Display posts from previous:   
Related Topics:
howto call excel XRA function with params from another modul Suppose I have a simple function in an Excel add-in: Sub mymacro() MsgBox "done" End Sub If this is made in to an add-in (XRA) and loaded OK, I can then place call this function from within another macro (in another sheet) like this: ("myx

VB app to call Media Player Hi ALL! I need to create a command button that will play an mp3 on Media Player. Can anyone help? Thanks in advance.

How to call Excel macro from VB6? Dear all, I need to write a VB program which calls an Excel macro but I am not sure how to do it..... Any suggestion or reference codes? Thanks a lot. Ivan

Dynamic call for MS Word Hi, I want to use MS Word as a reporting tool. I am using VB6.0 /w SP5 and Word 2002. I set MSWord 10.0 library in reference. The program works well. But the user is using Word 2000. How can I create a VB program suitable for both word 2000 and 2002 or la

ActiveX DLL Call rejected by callee Okay, having a bit of a nightmare so any help would be greatly appreciated as I think my head may explode soon. We have a Windows 2K server running SQL Server 7. A sp makes calls to an VB 6 ActiveX DLL that retrieves data from the database and inserts it
Post new topic   Reply to topic    msvisual.com Forum Index -> OLE Automation All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group