Converting Word macro for the Mac

B

banjotan

Version: 2004 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Hi everyone,

I'm looking for a way to combine multiple Word documents into a single document without copying and pasting or using the "Insert File" command. I work as an editorial assistant at a publisher, and this kind of macro would make creating files for the Library of Congress CIP program much faster!

I found a macro online (here: http://www.gaebler.com/How-to-Combine-Multiple-Word-Documents-Into-One-Document.htm), but a folder pointer looks like it will only work on a PC.

How would this be coded for the Mac?

Const strFolder = "C:\Book\Chapters\"

Here's the whole macro:

Sub MergeDocs()
    Dim rng As Range
    Dim MainDoc As Document
    Dim strFile As String
    Const strFolder = "C:\Book\Chapters\" 'change to suit
    Set MainDoc = Documents.Add
    strFile = Dir$(strFolder & "*.doc") ' can change to .docx
    Do Until strFile = ""
        Set rng = MainDoc.Range
        rng.Collapse wdCollapseEnd
        rng.InsertFile strFolder & strFile
        strFile = Dir$()
    Loop
End Sub

Thank you very much!

Jonathan
 
J

Jim Gordon Mac MVP

Version: 2004 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel
Hi everyone,

I'm looking for a way to combine multiple Word documents into a single
document without copying and pasting or using the "Insert File" command.
I work as an editorial assistant at a publisher, and this kind of macro
would make creating files for the Library of Congress CIP program much
faster!

I found a macro online (here:
http://www.gaebler.com/How-to-Combine-Multiple-Word-Documents-Into-One-Document.htm),
but a folder pointer looks like it will only work on a PC.

How would this be coded for the Mac?

Const strFolder = "C:\Book\Chapters\"

Here's the whole macro:

Sub MergeDocs()
Dim rng As Range
Dim MainDoc As Document
Dim strFile As String
Const strFolder = "C:\Book\Chapters\" 'change to suit
Set MainDoc = Documents.Add
strFile = Dir$(strFolder & "*.doc") ' can change to .docx
Do Until strFile = ""
Set rng = MainDoc.Range
rng.Collapse wdCollapseEnd
rng.InsertFile strFolder & strFile
strFile = Dir$()
Loop
End Sub

Thank you very much!

Jonathan

Hi Jonathan,

The Mac syntax uses colons instead of slashes. Try changing
"C:\Book\Chapters\"
to something liKe
"Hard Drive:Users:MACOSUserName:Documents:"

where MacOSUSernName is the name of the current MacOS account.

-Jim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top