This a view of the amended code, as per your advice
import arcpy
import os
import sys
import xlwt
import datetime
mxd=arcpy.mapping.MapDocument("current")
BUSID_TEMP=arcpy.GetParameterAsText(0)
LayersDF=arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
selLyr=arcpy.mapping.ListLayers(mxd, "FP_sample", LayersDF)[0]
for elm in arcpy.mapping.ListLayoutElements(mxd):
if elm.name=="GridTable": GridTable = elm
ddp=mxd.dataDrivenPages
arcpy.AddMessage(BUSID_TEMP)
pageID=mxd.dataDrivenPages.getPageIDFromName(str(BUSID_TEMP))
mxd.dataDrivenPages.currentPageID=pageID
#excel export part of the script
def table_to_excel(FP_sample, output, use_field_alias=False, use_domain_desc=False):
desiredFields=["Field1","Field3","Field4"] #desired fields for excel output
# Get the fields from the input
fields= arcpy.ListFields(in_table)
# Create a fieldinfo object
fieldinfo = arcpy.FieldInfo()
# Iterate through the fields and set them to fieldinfo
for field in fields:
if field in desiredFields:
fieldinfo.addField(field.name, field.name, "VISIBLE", "")
# The created view layer will have fields as set in fieldinfo object
arcpy.MakeTableView_management(FP_sample, "table_view", "", "", fieldinfo)
# To persist the layer on disk make a copy of the view
arcpy.TableToExcel_conversion("table_view", pop.xls)