AnsweredAssumed Answered

VBA FileSystemObject problem?

Question asked by Chris Day on May 18, 2012
Latest reply on May 21, 2012 by Chris Day



I'm trying to add functionality to a working macro, making the macro "remember" the last user input. Taking a page from Matthew Lorono's book [RevBlockAdd v1.13], I inserted this code just to check if a file is avaliable (as a first step).


    DefaultDrawn = swApp.GetCurrentMacroPathFolder             ' Get macro path

  DefaultDrawn = DefaultDrawn + "\AddRevision.ini"           ' Set source filename

  Set fso = CreateObject("Scripting.FileSystemObject")

  If fso.FileExists(DefaultDrawn) Then                       ' Does source file exist?

    Set DefaultDrawnFile = fso.OpenTextFile(DefaultDrawn, 1)

      MsgBox ("AddRevision.ini exists"), vbInformation


      MsgBox ("AddRevision.ini does not exist"), vbInformation

  End If


When I run the macro, I get the error "Object variable or With block variable not set," which points to the line where the UserForm which contains the code above is loaded.

I installed SCRRUN.DLL using the Insert > Components and browsing for the DLL in Window's System32 folder. It didn't seem to add any lines of code.


As far as I can see the code is identical to the code in RevBlockAdd except for some changes in variable names. Is there anything else I need to include that I'm missing? I've attached my macro if a more in-depth look is required.


Thanks in advance.