Cross-posted in the Access Forum.
To prevent duplicate and diverging threads, all replies there please <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

<img src=/w3timages/blackline.gif width=33% height=2>

Hi

I am developing an Access database which links up with various Visio Office layout diagrams.

I have managed to use VBA to read all the Custom properties set up on the shapes for the PC's and use them to update the tblPC table in the database.

However, I have got a problem in trying to update the Custom properties using VBA. Here is the code I am using :

'
'---------------------------------------------------------------
'Initialise Visio Variables
'---------------------------------------------------------------
Set objVSApp = New Visio.Application
objVSApp.Visible = False
Set objVSDoc = objVSApp.Documents.Open(strFileName)
Set objVSLayers = objVSApp.ActivePage.Layers
Set objVSShps = objVSApp.ActivePage.Shapes
DoEvents
'
'---------------------------------------------------------------
'Initialise Access Variables
'---------------------------------------------------------------
strSQL = "SELECT * FROM tblPC WHERE tblPC.FileName ='" & strFileName & "';" Set rst = CurrentDb.OpenRecordset(strSQL, dbOpenSnapshot) Set rstTable = CurrentDb.OpenRecordset("tblVisioProps", dbOpenSnapshot) '
'---------------------------------------------------------------
'Loop through all the shapes on the table & update the
'Visio diagram with the values
'---------------------------------------------------------------
rst.MoveFirst
Do Until rst.EOF
Set objVSShp = objVSShps(rst!ShapeID)
intRowCount = objVSShp.RowCount(Visio.visSectionProp)
rstTable.MoveFirst
For intCellCount = 0 To intRowCount - 1
If IsNull(rst(rstTable!FieldName)) Or Len(rst(rstTable!FieldName)) = 0 Then
'Do nothing
Else
Set objVSCell = objVSShp.CellsSRC(Visio.visSectionProp,
intCellCount, 0)
objVSCell.Result(Visio.visNone) = rst(rstTable!FieldName)
End If
rstTable.MoveNext
Next
rst.MoveNext
Loop

The line where it fails is :

objVSCell.Result(Visio.visNone) = rst(rstTable!FieldName)

It comes up with a type mismatch 13 error. The field is a text(255) field, and the value to be inserted is 'Compaq'. Any ideas on how to get this one to work ?

All help much appreciated

Thanks

Nick