Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding Shared Workbooks in Excel 1

Status
Not open for further replies.

StewartJ

Programmer
Apr 3, 2002
74
GB
My Visual FoxPro 6 code programmatically opens an Excel workbook through COM with objExcel.Application.Workbooks.Add(<Filename>)

This works fine except when the workbook is marked for sharing. In that case, it loads OK but immediately displays a Save As dialog with the default filename of the original plus the character '1'. <Filename>1 does not exist in my registry, code or anywhere else on my machine that I can detect. The workbook does not contain any macros and AutoSave is off. Can anyone explain this?
 
objExcel.Application.Workbooks.Add(<Filename>)

Replace with:
objExcel.Application.Workbooks.Open(<Filename>)

Works for me.
 
And having taken the dog for a walk and cleared my head, I can tell you why. Whenever you create a shared spreadsheet, either by setting it to shared or by creating from a template which is what .add is doing, the workbook must be saved for the sharing to be enabled.

I think, but can't guarantee, that you can open from Foxpro. I could only test this by setting up a reference from another prog myself. Not when you've got one nicely set up to test.
Let us know if it works.
 
Thanks for both - a star each! Both the explanation and the solution work fine. Many thanks.

(The only thing that happened to me when I took the dog for a walk this morning is that I got rained on!)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top