Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Removing multiple sheets in excel automation
Message
 
To
21/12/2013 00:29:38
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01590748
Message ID:
01590752
Views:
73
This message has been marked as a message which has helped to the initial question of the thread.
>I have set this up to remove all multiple sheets except the first sheet.
>It's not working - any help would be appreciated. thanks
>k
>
>
>lcFile='myfile.xlsx'
>Erase (Forceext(lcFile,'xxx'))
>ox=Createobject('excel.application')
>owb=ox.Workbooks.Open(lcFile)
>
>If owb.Sheets.Count > 1
>	Nu= owb.Sheets.Count
>	ms=1
>	Do While ms < Nu+1
>		mname=owb.Sheets(m1).Name
>		If ms>1
>			Wait Window 'removing '+ mname timeout 2
>			owb.Sheets(mname).Delete
>		Endif
>		ms=ms+1
>	Enddo
>Endif
>ox.Visible=.T.
>
lcFile='myfile.xlsx'
ox=Createobject('excel.application')
owb=ox.Workbooks.Open(lcFile)

If owb.Sheets.Count > 1
    Nu= owb.Sheets.Count
    Do While Nu > 1
        mname=owb.Sheets(Nu).Name
        Wait Window 'removing '+ mname timeout 2
        owb.Sheets(mname).Delete
        Nu= owb.Sheets.Count
    Enddo
Endif
ox.Visible=.T.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform