With ActiveSheet.PageSetup .PrintTitleRows = "$1:$2" .PrintTitleColumns = "" .PrintArea = "$B:$I" End With #### my $pl = ""; open(TXT, ") { s/\./->/; s/=/=>/; s/"/'/g; s/\s+End With/);/; s/\s+With (\w+)->(\w+)/\$Range = \$$1->$2;\nwith (\$Range/i; s/(.*[^;])\n/$1,\n/; $pl .= $_; } close(TXT); open(TXT, ">mymacro.pl"); print TXT $pl; close(TXT); #### $Range = $ActiveSheet->PageSetup; with ($Range, PrintTitleRows => '$1:$2', PrintTitleColumns => '', PrintArea => '$B:$I', );