3

I am beginner in VBA. I have created a Template in Word (.dotm). I have used 30 String object. I don't know whether VBA dispose it or do I need to dispose it manually.

Can anybody please suggest me so I will not have problem of memory in future?

1
  • 3
    See e.g. this answer. Commented Sep 8, 2016 at 6:56

1 Answer 1

4

No need to dispose. As soon as the string variable is out of scope, the memory is recovered.

'Globally scoped g will be retained until the project is reset with `End`
Public g as string

Sub foo()
  Dim s as string
  s = "foo"

  g = "bar"

's is destroyed on exiting the sub
End Sub

Sub bar()
  ' Reset the project will reclaim all variables including Globals
  End
End Sub
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.