0

I am writing an HMI application in Rockwell's FactoryTalk View and would like to use VBA to open a file and read text. I have included the reference to Microsoft Office 16.0 Object Library so I can use fileDialog. The method is available now and I have found examples of how to do this for Office applications e.g.

Dim fileName as fileDialog
Set filename = Application.FileDialog(msoFileDialogPicker)

but the Set statement fails because fileDialog is not a method in this application. I would appreciate any input on the easiest way to get around this. I assume I need to create on Office Application object even though I am only invoking it for the file dialog browser.

  • 1
    Yes you'd need something like `Set app = CreateObject("Excel.Application")` and then `Set filename = app.FileDialog(msoFileDialogPicker)` You may need to make the Excel instance visible to see the dialog. – Tim Williams Mar 18 '19 at 02:00
  • 1
    If using Office apps is not a must, you can utilise Shell calling mshta, see solution for https://stackoverflow.com/questions/21559775/vbscript-to-open-a-dialog-to-select-a-filepath. Dim `wShell` & `oExec` as Objects. – PatricK Mar 18 '19 at 02:09
  • Thanks. Actually I did not want to use office at all, it was just the only way I could figure out how to do it so far. I will investigate the Shell method. –  Mar 19 '19 at 03:54

0 Answers0