I have a vba script that only update the active dgn file. the script is written to search a few selected files and change the selected text.
I am using microstation v8i. I am new to vba programming so any help will be appreaciated.
the previouse post i have deleted them so only reffer to this post. i have attached the vba script.
thank you guys for your help so far.
Jon can you recommend the best book to acquire to self teach mvba. Thanks again guys.
Unknown said: can you recommend the best book to acquire to self teach mvba.
can you recommend the best book to acquire to self teach mvba.
The Learning MicroStation VBA book is a good suggestion.
This is the same book i have. i am having problems with some of the codes
Even if i take it from the cd. They gave me error not sure why.
If you could provide details regarding the issues you are having... one issue per thread, some suggestions to help could be provided.
.
Hi,
In your vba, when you click the button, you have a For I =... loop. In that loop, you need to open each file:
OpenDesignFile lstFilesToProcess.List(I - 1)
and then at the end of everything, you need to complete the "for next" loop with a "Next" statement.
--Robert
Robert, Is there a way to ask you a question from the past or do I need to start a new post on the question. The forum was closed
RJB Phillips III - Praise the Lord for His Mercy and Grace
If your question relates specifically to the topic in this thread, then it is okay to ask in this thread. If the question relates to another topic, then it would be best to start a new thread (and include details that would help anyone determine what you are asking, including reference to other content within this site... if that is the case).
I can see that your VBA macro successfully populates a ListBox with DGN files.
What exactly doesn't work subsequently?
Regards, Jon Summers LA Solutions
Thank you Robert
Thank you for replying to my post. After the go button is selected the program should have scan the files in the list box and find and replace the word man to woman. The program only find and replace the word man with woman in the active file.
With comments and unnecessary macro recorder code removed, your GO function boils down to this …
Private Sub btnGo_Click() Dim fileName As String Dim I As Long For I = 1 To lstFilesToProcess.ListCount fileName = lstFilesToProcess.List(I - 1) Debug.Print fileName Next I CadInputQueue.SendCommand "MDL KEYIN FINDREPLACETEXT" ... CadInputQueue.SendCommand "FILEDESIGN" CommandState.StartDefaultCommand End Sub
In a For loop, you trace the contents of your ListBox. Next, after the For loop has finished, you perform a text search-and-change operation.
What you should be doing in your For loop is opening a DGN file for edit …
Private Sub btnGo_Click() Dim I As Long Dim fileName As String Dim oDgnFile As DesignFile For I = 1 To lstFilesToProcess.ListCount fileName = lstFilesToProcess.List(I - 1) Debug.Print fileName Set oDgnFile = OpenDesignFile (fileName) ' Process file's contents ProcessActiveDesignFile Next I CommandState.StartDefaultCommand End Sub
Put whatever you want into method ProcessActiveDesignFile. In your case, put all the text change code …
Function ProcessActiveDesignFile () As Long CadInputQueue.SendCommand "MDL KEYIN FINDREPLACETEXT" CadInputQueue.SendKeyin "FIND DIALOG SEARCHSTRING MAN" CadInputQueue.SendKeyin "FIND DIALOG REPLACESTRING WOMAN" CadInputQueue.SendCommand "CHANGE TEXT ALLFILTERED" CadInputQueue.SendCommand "CHANGE TEXT FIND" CadInputQueue.SendCommand "CHANGE TEXT ALL" CadInputQueue.SendKeyin "task sendtaskchangedasync" CadInputQueue.SendKeyin "task sendtaskchangedasync ""\Drawing""" CadInputQueue.SendCommand "FILEDESIGN" End Function
Answer Verified By: bobby rag