Macro doesn't run on Word:mac 2011

Discussion in 'Word VBA' started by hans.list@gmail.com, Oct 27, 2013.

  1. Guest

    I'm trying to get this macro (that I found on the web) to run on my Mac. It gives an error in the line that starts with "strFile":

    Sub DocsToDocx()
    Dim strPath As String
    Dim strFile As String
    Dim doc As Document
    ' Path should end with semicolon
    strPath = "SSD:Users:Hans:Dropbox:CT:prj:test:"
    strFile = Dir(strPath & "*.doc") 'error here
    End
    Do While strFile <> ""
    If Right(strFile, 3) = "doc" Then

    Set doc = Documents.Open(fileName:=strPath & strFile)

    If doc.HasVBProject Then
    doc.SaveAs fileName:=strPath & strFile & "m", _
    FileFormat:=wdFormatXMLDocumentMacroEnabled
    Else
    doc.SaveAs fileName:=strPath & strFile & "x", _
    FileFormat:=wdFormatXMLDocument
    End If
    doc.Close SaveChanges:=False
    End If
    strFile = Dir
    Loop
    End Sub

    How can I fix this?

    Many thanks!

    Hans
     
    , Oct 27, 2013
    #1
    1. Advertisements

  2. Guest

    Found it ...

    Sub DocsToDocx()
    Dim strPath As String
    Dim strFile As String
    Dim doc As Document
    ' Path should end with semicolon
    strPath = "SSD:Users:Hans:Dropbox:CT:prj:test:" 'you have to set this to your own path ...
    strFile = Dir(strPath, MacID("W8BN")) 'error here

    Do While strFile <> ""
    If Right(strFile, 3) = "doc" Then

    Set doc = Documents.Open(fileName:=strPath & strFile)
    doc.SaveAs fileName:=strPath & strFile & "x", _
    FileFormat:=wdFormatXMLDocument

    doc.Close SaveChanges:=False
    End If
    strFile = Dir
    Loop
    End Sub
     
    , Oct 27, 2013
    #2
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.