View Single Post
 
Old 12-16-2011, 04:46 PM
Joe Patrick Joe Patrick is offline Windows 7 64bit Office 2007
Advanced Beginner
 
Join Date: May 2011
Posts: 33
Joe Patrick is on a distinguished road
Default How to create a system folder with VB macro?

Hi!

I have this code that works from Excel but from Word I get an error 13/type mismatch.

Can anyone help me make this work from Word, please?

Code:
Sub CreateNewFolder()
Dim _
fso As FileSystemObject, _
fol As Folder, _
fol_add As Folder, _
fil As File
Const strFolPath As String = "\\Fileserver\commonh\GROUP\SDF_data_export"
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fol = fso.GetFolder(strFolPath)
 
    On Error GoTo Finish
        If Not fso.FolderExists(strFolPath & "\" & ThisDocument.Textbox59.Value) Then
            Set fol_add = fso.CreateFolder(fol.Path & "\" & ThisDocument.Textbox59.Value)
        End If
    End If
 
    Set fso = Nothing
    Set fol = Nothing
 
End Sub
Reply With Quote