Notes to Word little problem

Hi, I´m trying to export some fields from a view to a Word without a template and i want to know how to start writing in a new line.

For example:

With wordObj.Selection

		.ParagraphFormat.Alignment = wdAlignParagraphCenter

		.Font.Name = "Arial"

		.Font.Size = 14

		.Font.Bold = True

		.TypeText("Nombre del Club:   ")

.TypeText(NEW LINE) <—

	.TypeText(doc.GetItemValue("nombre_club")(0))

		.TypeText("Calle: ")

.TypeText(NEW LINE) <—

.TypeText(doc.GetItemValue(“direccion_club”)(0))

	End With  

Thank you.

Subject: Here is my ms word export code… I use tables for formatting

hope this helps:

Declarations:

Const wdItem = 16

Const wdCell = 12

Const wdFormatDocument = 0

Const wdGoToTable = 2

Const wdInsertCellsEntireRow = 2

Const wdInsertCellsShiftDown =1

Const wdLine =5

Const wdCharacter = 1

Const wdPageBreak = 7

Const wdAutoFitContent=1

Const wdExtend=5

Const END_OF_STORY = 6

Dim session As notessession

Dim db As NotesDatabase

Intitalize:

Sub Initialize

On Error Goto errtrap

Dim session As New NotesSession

Dim db As notesdatabase

Dim vc As notesviewentrycollection

Dim entry As notesviewentry

Dim x As Integer	

Dim ws As New NotesUIWorkspace

Dim uiview As NotesUIView



Dim doc As NotesDocument

Dim item As NotesItem

Dim contents As String

Dim holdseq1,holdseq,p As Integer



Set db = session.CurrentDatabase

’ Set uiview = ws.CurrentView

’ viewalias$=uiview.ViewAlias

’ Set view=db.GetView(viewalias$)

Set view=db.GetView("TOC")





Set vc = view.AllEntries





If vc.Count=0 Then

	Msgbox "no documents!!"

	Exit Sub

End If



Dim numtxt As String

’ numtxt$ = Cstr(Inputbox$(“Enter Chapter Number”))

numtxt$=db.Title

’ If Trim(numtxt$)=“” Then

’ Msgbox “Operation cancelled!”

’ Exit Sub

’ End If

Set wordapp = CreateObject("Word.Application") 'Create Word object

’ wordapp.Visible = False

wordapp.Visible = True

Call wordapp.documents.add



Set worddoc = wordapp.activedocument 'Get a handle for the active document



Set entry=vc.GetFirstEntry



x=1

p=1

While Not entry Is Nothing

	Set doc = entry.Document

	holdseq=doc.SectionNum(0)

’ numtxt$="Sequence: " & Cstr(holdseq)

	Call createTable(session,db,wordapp,worddoc,vc,entry,doc,x,numtxt,p)	

	

	x=x+1

	Set entry= vc.GetNextEntry(entry)

	If Not entry Is Nothing Then

		Set doc2 = entry.Document

		holdseq1=doc2.Sequence(0)

		If holdseq = holdseq1 Then

			p=p+1

		Else

			p=1

		End If

	End If

Wend



wordapp.Visible = True

Exit Sub

errtrap:

wordapp.Visible = True

ERRtxt= "Error: "  & " : " & Str(Err) & ": " & Error$	

Print ERRtxt	

Msgbox ERRtxt	

Exit Sub		

End Sub

Sub createTable(session As NotesSession,db As NotesDatabase,wordapp As Variant,worddoc As Variant,vc As notesviewentrycollection,entry As NotesViewEntry,doc As NotesDocument,x As Integer,numtxt As String,p As Integer )

’ On Error Resume Next

On Error Goto TABLEERROR

With Wordapp

	Print "Processing " & Cstr(x) & " of  " & Cstr(vc.Count) & " : " & Trim(doc.Title(0))

'Create the Issue Log table with 8 columns and how ever many rows we decided we needed earlier

’ .ActiveDocument.Tables.Add wordapp.Selection.Range, 4,8

	.ActiveDocument.Tables.Add wordapp.Selection.Range, 4,1

’ .ActiveDocument.Tables(x).Add wordapp.Selection.Range, 4,4

'Reduce horizontal padding in cells; don’t allow rows to break across pages; set all cells to font size 9

	.Selection.Tables(1).Select

	.Selection.Borders.Enable =True

	'	.Selection.Borders.Enable =False

	'	.Selection.Rows.AllowBreakAcrossPages = False

	.Selection.Rows.AllowBreakAcrossPages = True

	

	.Selection.ParagraphFormat.SpaceBefore = 5 

	.Selection.ParagraphFormat.spaceBeforeAuto  =True 

	.Selection.ParagraphFormat.SpaceAfter = 5 

	.Selection.ParagraphFormat.SpaceAfterAuto = True 

	.Selection.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle 

	.Selection.ParagraphFormat.CharacterUnitFirstLineIndent = 0 

	.Selection.ParagraphFormat.LineUnitBefore =0 

	.Selection.ParagraphFormat.LineUnitAfter = 1

'Repeat table headings on each new page; set table headings font to bold

	.Selection.Tables(1).Rows(1).HeadingFormat = True

	.Selection.Font.Bold = True

	.Selection.Font.Size = 12

	.Selection.Font.Bold = True	

	

	'ROW 1		db title

'	.Selection.TypeText  Trim("Chapter " & numtxt)

	.Selection.TypeText  Trim(numtxt)	

	.Selection.Tables(1).Rows(1).Select

	.Selection.MoveDown wdLine

	.Selection.Font.Bold = True

	.Selection.Font.Size = 12

	.Selection.Font.Bold = True	

	

	'row 2

	.Selection.TypeText  Trim(Cstr(doc.SectionNum_1(0)) & ". " & doc.Section(0))

	.Selection.MoveDown wdLine

	

	.Selection.Font.Size = 9	

	

	'ROW 3

'	.Selection.TypeText "Title"

'	.Selection.TypeText Chr(10) & doc.Topic(0)		

	.Selection.TypeText Trim(Cstr(doc.SectionNum(0)) & ". " & doc.Topic(0)	)	

’ .Selection.MoveDown wdLine

	.Selection.MoveDown wdLine

	

	.Selection.Font.Size = 9	

	.Selection.Font.Bold = False

	

	

	.Selection.ParagraphFormat.SpaceBefore = 5 

	.Selection.ParagraphFormat.spaceBeforeAuto  =True 

	.Selection.ParagraphFormat.SpaceAfter = 5 

	.Selection.ParagraphFormat.SpaceAfterAuto = True 

	.Selection.ParagraphFormat.LineSpacingRule = wdLineSpaceSingle 

	.Selection.ParagraphFormat.CharacterUnitFirstLineIndent = 0 

	.Selection.ParagraphFormat.LineUnitBefore = 0 

	.Selection.ParagraphFormat.LineUnitAfter = 0 

	

	'GetRichTextContent(doc As NotesDocument, db As NotesDatabase, session As NotesSession)

	Dim RText As NotesRichTextItem 

	Dim RTNav As NotesRichTextNavigator

	

	Dim RTRange As NotesRichTextRange

	Dim count As Integer

	Dim TextString As String

	

	If doc.HasItem("Body") Then

		Set RText = doc.GetFirstItem("Body")

		If (RText.Type = RICHTEXT) Then

			

			Set RTNav = RText.CreateNavigator

			Set RTRange = RText.CreateRange

			

			If RTNav.FindFirstElement(RTELEM_TYPE_TEXTPARAGRAPH) Then

				count% = 0

				

				Do

					count% = count% + 1

					Call RTRange.SetBegin(RTNav)

					

					TextString$ = TextString$ + RTRange.TextParagraph

					

					

				Loop While RTNav.FindNextElement(RTELEM_TYPE_TEXTPARAGRAPH)

				

			End If

			

			

		End If

	End If

	

	

	wordapp.Selection.TypeText Chr(10) & Trim(TextString$)

%REM

’ .Selection.Cells.Merge

’ ROW 4

	Set item = doc.GetFirstItem( "Body" )

	contents = Fulltrim(item.Text)

	cValue=Replace(contents,";",Chr(13))

%END REM

'	cValue=TextString$

	.Selection.TypeText Chr(10) & Trim(cValue)

	

'		.Selection.Tables(1).AutoFitBehavior (wdAutoFitContent)

	.Selection.EndKey END_OF_STORY	

	.Selection.TypeParagraph	

'	.Selection.Insertbreak wdpagebreak		

End With

Exit Sub

TABLEERROR:

'Msgbox "ERROR WITH #" & Cstr(x) & " : "& DOC.DESCRIPTION(0)

Print "ERROR WITH #" & Cstr(x) & " : "& DOC.Topic(0)

ERRtxt= "Error: "  & Str(Err) & ": " & Error$	

Print ERRtxt	

Msgbox ERRtxt

Resume Next

End Sub

Subject: Notes to Word little problem

Wow !!!I just tried to find this: “.Selection.TypeParagraph” and I get a complete example.

Thanks

Subject: Hope it helps

I’ve gotten a lot of great code from these forums over the years. I have no problem sharing things that work.