Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

VBA & Element ID to Add text.

$
0
0

I am working on a project for a client that doesn't use Reference Files and have nearly 1K files I need to adjust the revision # for and add in 2 signatures.  I am running into problems.  This is my first time writing in VBA, and most of my script has been pulled from multiple sources.  I get the script to run but it doesn't seem to have changed anything in the first file, and the rest are untouched.  Any help would be super duper appreciated.

Sub Test()
Dim fso As New FileSystemObject
Dim fld As Folder
Dim f As File
Dim dgn As DesignFile
Dim elem As Element'Folder Location of .dgn files
Set fld = fso.GetFolder("C:\Users\mneist\Desktop\batchprocesstestfiles")
For Each f In fld.Files'If InStr(LCase(f), ".dgn") > 0 Then
        Set dgn = Application.OpenDesignFileForProgram(f)'Silent Load File'opendgnforprogram dgn
        Dim elementObj As Element'Example'        Dim id As DLong'        id.Low = Numerical ID EX'        Set elem = dgn.GetElementByID(id)'        If elem.IsTextElement Then'        elem.AsTextElement.Text = "Example Text"'        elem.Rewrite'        elem.Redraw'        End If'Examined
        Dim id As DLong
        id.Low = 3451
        Set elem = dgn.GetElementByID(id)
        If elem.IsTextElement Then
        elem.AsTextElement.Text = "ExaminersName"
        elem.Rewrite
        elem.Redraw
        End If'Approved
        id.Low = 345
        Set elem = dgn.GetElementByID(id)
        If elem.IsTextElement Then
        elem.AsTextElement.Text = "ApproversName"
        elem.Rewrite
        elem.Redraw
        End If'Revision #
        id.Low = 23249
        Set elem = dgn.GetElementByID(id)
        If elem.IsTextElement Then
        elem.AsTextElement.Text = "0"
		elem.Rewrite
        elem.Redraw
        End If
        dgn.Save'End If
Next

End Sub

Viewing all articles
Browse latest Browse all 7260

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>