1 Reply Latest reply on May 30, 2017 10:20 AM by Deepak Gupta

    VBA - Get Sheet Properties Error

    Rebecca Bemrose-Fetter

      I am modifying a macro I found here to allow me to do a batch change of the sheet format for all the drawings in a folder (without losing the scale for each sheet). I attached the code.

       

      My problem occurs when it opens a drawing with multiple sheets (seems to work fine for single sheet drawings). Our sheets are usually (but not always) named 1, 2, 3, etc. The first multi-sheet drawing it finds happens to open to a sheet named 3. It renames this sheet to 1 (the value of swSheetName). On the second iteration, for sheet 2, it is fine, then on the third iteration through the For loop it returns a Run-time Error 91; Object variable or With block variable not set. Does it do this because now there are two sheets named the same thing? (the original 1 and the sheet 3 that it named 1)

       

      What can I do so that it doesn't change the sheet name, just cycles through them? Will that solve the problem?

       

      Thanks for your help.