none
VBA - Object variable or With block variable not set RRS feed

  • Question

  • Wasn't quite sure which forum was appropriate.  I have a couple of macros which I have used for several years in Word 2010 to do a mail merge and output to individual PFD files and then email the files to individual people.  I have just upgraded to Windows 10 and suddenly the first macro is failing with, "Object variable or With block variable not set".  The macro is only doing a text substitution, saving the modified file and uploading the template for the next merge.  It is failing on the first object call it makes,

      With Selection.Find
        .ClearFormatting
        .Text = tag(I)
        .Replacement.ClearFormatting
        .Replacement.Text = data(I)
        .Execute Replace:=wdReplaceAll, Forward:=True, Wrap:=wdFindContinue
      End With

    Is there some change to the underlying VBA execution in Windows 10 that need some extra declaration?

    many thanks,


    Alex

    Thursday, August 13, 2015 5:02 PM

Answers

  • In all likelihood, the Windows 10 upgrade has damaged your Office installation (there seems to have been a lot of that). Try repairing the Office installation (via Start > Windows Control Panel > Programs > Programs & Features > Microsoft Office (version) > Change).

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Friday, August 14, 2015 8:11 AM

All replies

  • This forum supports Visual Basic in Visual Studio (VB 7 and later). You seem to be using Visual Basic for Applications (VBA) in Word.

    For help with the VBA language, try the VBA Forum

    For help using VBA in Excel, try the Word for Developers Forum

    Thursday, August 13, 2015 5:30 PM
  • In all likelihood, the Windows 10 upgrade has damaged your Office installation (there seems to have been a lot of that). Try repairing the Office installation (via Start > Windows Control Panel > Programs > Programs & Features > Microsoft Office (version) > Change).

    Cheers
    Paul Edstein
    [MS MVP - Word]

    Friday, August 14, 2015 8:11 AM