Results 1 to 3 of 3

Thread: Loop to open Word Docs - Avoid Maximizing Already Open Doc

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Regular
    Joined
    Apr 2017
    Posts
    66
    Location

    Loop to open Word Docs - Avoid Maximizing Already Open Doc

    The code below opens Word docs using file paths in each cell in Excel range.

    Code works to open the docs OK, but the issue is that it will also maximize one unrelated, already open Word doc (if it exists) that is minimized to the tool bar.

    Is there a way to avoid this?

    Dim Shex As Object
    Set Shex = CreateObject("Shell.Application")
    Dim rng As Range
    Dim ws As Worksheet
    Set ws = Worksheets("FilePaths")
    NumRows = Range("B2", Range("B1").End(xlDown)).Rows.Count
    Set rng = ws.Range("B2:B" & NumRows + 1)
    For Each cell In rng
        Shex.Open cell.Value
    Next cell
    End Sub
    Last edited by Aussiebear; 03-12-2025 at 09:25 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •