Home > Net >  Using swModel.CreateText for multiline notes with checkboxes
Using swModel.CreateText for multiline notes with checkboxes

Time:12-29

I'm writing a macro that takes multiple checkboxes and loops through them to insert the standard notes into a single note. This is my code:

enter image description here

This is what I have. What it should be doing is taking each checkbox caption and adding it to a new line in a single note. What it's doing is creating a new note for each caption with a space at the end. I've tried moving that line of code around, but this is my first time using VBA and I've ran out of ideas. What can I do to have it create a single note and adaptively add all chosen captions into it?

CodePudding user response:

The CreateText shouldn't be in the For loop

Try this:

Dim MyStr As String
For Each ThisControl2 In Prompt.Controls
   If TypeName(ThisControl2) = "CheckBox" Then
      If ThisControl2.Value = True Then
         MyStr = Mystr & ThisControl2.Caption & vbCrLf
      End If
   End If
Next
swModel.CreateText MyStr, 0.02, 0.02, 0, 0.003175, 0
  • Related