Hi there,

I've just started with vba scripting in word 2010. So bear with me if some of my questions are on a lower level.

I'm trying to create a catalouge and use word 2010 as a template. I'm using a mysql database on a ubuntu with phpmyadmin. There I'm creating a generic database to store information to import into the catalogue.

The approach I'm heading now involes the following steps:

1. export a csv file from the database
2. Use mailmerge to paste these csv onto the word template.
3. Create a macro that automaticly finds these csv text strings and convert them to to word tables (recorded a macro on the "convert text to table" function).

These steps aren't really a problem when it comes to creating just one table (Though I'd have to select the csv text manually to create the first table). But as I said I want to create tables for all the mailmerged csv textstrings.

My problem is my inablility to navigate and select next csv textstring. I've tested
1. Selection.moveDown
2. .MoveUntil
3. Selection.Find

I'll post my attempts here, note that these are on a very beginner level.

I'd appriciate if someone could point me in the right direction/tell me if what I'm doing even is possible.

[vba]

Sub Macro1()
'
' Macro1 Macro
'
'



'// This code creates the first table if it's manually selected
Selection.ConvertToTable Separator:=wdSeparateByCommas, NumColumns:=3, _
NumRows:=4, AutoFitBehavior:=wdAutoFitContent
With Selection.Tables(1)
.Style = "Table Grid"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False

End With



'With Selection.Find
'.ClearFormatting
'.Text = "APPLIKATIONSTABELL"
'.Replacement.ClearFormatting
'.Replacement.Text = "hello"
'.Execute Replace:=wdReplaceAll, Forward:=True, _
'Wrap:=wdFindContinue


'End With

'// Failed attempts to move to the next csv textstring
Selection.MoveDown Unit:=wdLine, Count:=20
Set myRange = ActiveDocument.Words(1)
myRange.MoveUntil Cset:="APPLIKATIONSTABELL", Count:=100

'// Failed attempt to create a second table
'Selection.MoveRight Unit:=wdLine, Count:=16
Selection.ConvertToTable Separator:=wdSeparateByCommas, NumColumns:=3, _
NumRows:=4, AutoFitBehavior:=wdAutoFitContent
With Selection.Tables(1)
.Style = "Table Grid"
.ApplyStyleHeadingRows = True
.ApplyStyleLastRow = False
.ApplyStyleFirstColumn = True
.ApplyStyleLastColumn = False


End With

'// Attempt to understand how to navigate
'MsgBox "Line " & Selection.Information(wdFirstCharacterLineNumber)
'Selection.MoveDown Unit:=wdLine, Count:=20, Extend:=wdMove
'MsgBox "Line " & Selection.Information(wdFirstCharacterLineNumber)

'Selection.MoveDown Unit:=wdLine, Count:=1



End Sub

[/vba]

Erik Alm