Question

I have a macro that will move data from a "source" document into a "destination" document. I want the user to be able to choose which of the already-open documents should be the source, and which should be the destination.

If I used an InputBox for each stage, the user would have to type the name of the file exactly, and sometimes those names are long. I'd prefer to display a dialog or list of the open documents and let the user select one as the source, then display another dialog to select the destination.

Any ideas how to do that?

Was it helpful?

Solution

Pankaj, when I saw your comment and thought about looping through the open documents to populate the userbox, I realized I could populate the InputBox with the list of documents and have the user choose them by number:

' Make list of open Documents
For i = 1 To Documents.Count
    s = s & vbCr & i & " " & Documents(i).Name
Next i

Set SourceDoc = Documents(Val(InputBox("Choose Source Document: " & s))) ' User enters number of desired doc
Set DestinationDoc = Documents(Val(InputBox("Choose Destination Document: " & s))) ' User enters number of desired doc

Thanks!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top