VBA word 2010 Common dialog box licence problem

MrDavidThorn used Ask the Experts™
Hi Experts

I have designed a macro enabled word document with a form that contains a common dialog box, works fine on my own machine, when the document is opened by other users  - they can not access the common dialog box due to MS licence issues (http://dutchgemini.wordpress.com/2010/12/23/vba-cannot-create-mscomdlg-commondialog-activex/) - I can resolve the problem using the reg fix in the url, however Im unsure of licence restriction and dont want to tempt fate, is there away to get around the common dialog licence problem (doesnt make sense as all users have it install anyhow)  - or can I use an API call for a user to select a file (its an Excel file the user needs to select)

Dim cdExcelFile As Object

Set cdExcelFile = VBA.CreateObject("MSComDlg.CommonDialog")
cdExcelFile.DialogTitle = "Select new source file"

cdExcelFile.Flags = cdlOFNFileMustExist + cdlOFNPathMustExist
cdExcelFile.Filter = "Microsoft Excel Workbooks (*.xls;*.xlsx;*.xlsm)|*.xls;*.xlsx;*.xlsm;"

Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2012
I suggest that you use the FileDialog from Office. Here is some sample code :
Sub InsertPics()
    Dim fd As FileDialog
    Dim rng As Range
    Dim ilsh As InlineShape
    Set fd = Application.FileDialog(msoFileDialogFilePicker)
    Dim strFileName As Variant
    With fd
        .Filters.Add "All files", "*.*"
        .Filters.Add "Images", "*.gif; *.jpg; *.jpeg", 1
        If .Show Then
            Set rng = Selection.Range
            rng.Collapse wdCollapseEnd
            For Each strFileName In .SelectedItems
                Set ilsh = ActiveDocument.InlineShapes.AddPicture(strFileName, False, True, rng)
                Set rng = ilsh.Range
                rng.Collapse wdCollapseEnd
                rng.Text = vbCr & vbCr
                rng.Collapse wdCollapseEnd
            Next strFileName
        End If
    End With

End Sub

Open in new window

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial