It appears that there is a documents “collection” object of open documents. I appear to be able to refer to an open document via its item number ( Index ) or name, like
Or for short
So I could, for example Activate that opened document with
I can do very similar to that in Excel VBA,
I can use a variable for my Workbook object like this:_..
Dim Wb As Workbook
_Set Wb = Workbooks("MyExcelFile.xlsx")
_..then I can refer to the Workbook via that variable.
So for example, having done that declaration I can do like:
I can’t seem to find any documentation on how to do something similar in Word VBA, pseudo like:
Dim Doc As Document
_Set Doc = Documents("MyWordFile.docx")
Does anyone know if I can do that?
Maybe this is all a bit of a different World to the VBA Excel one that I know about.
am I just a Dim Doc.?
P.s. What I actually want to do is determine the Active document at the start of a code in such a way that I can then safely refer to it later and not get mixed up if other documents start getting opened, etc.
This would be one way, that seems to work: _..
Dim DocNme As String
_Let DocNme = ActiveDocument.Name
_.. then later I can do like refer to that with
_.. I am puzzled that I cannot seem to refer to a Word document object as I can to an Excel Workbook object.