Accessing Excel worksheets in a Word document (VB macro).
Hello, would you please assist me in solving this problem:
I have an Excel object (Excel.Sheet.1) in MS Word document. I'm trying to write a Visual Basic macro for MS Word to change the data in cell A1 of this table. How can I access the cell? I'll try to describe the table I have to work with: It's not a Word table. It's rather an Excel object present in my Word document. When it's activated a real Excel table with 3 sheets appears.. and if it's not activated, I just see a simple table which doesn't differ from a regular Word table. I would say it's an Excel OLE placed in the Word document I have to deal with. I was adviced to open Excel by using a filename but I don't have a separate Excel document which I open by using its name... I've applied the next to find out the name of my object: :: Code :: MsgBox ActiveDocument.Fields(1).OLEFormat.ProgIDThe result is: Excel.Sheet.1 What I've surely succeeded to do is activating the object. And it seems there are various ways of obtaining that, for example: :: Code :: ActiveDocument.Fields(1).DoClick
ActiveDocument.Fields(1).OLEFormat.Edit ActiveDocument.Fields(1).OLEFormat.Activate ... and no way known to me to edit the object's contents... I suppose I have to apply DDE to the object in order to open Excel, edit it and then close Excel... I don't know how to do it yet... I hope that it's an easy task some one has already an idea of.. Thank you! Back to top |
Sorry, that's too obscure for anyone here I guess.
Trying to get two different microsoft applications to talk to each other with vba, that doesn't sound very fun to be honest. Anyway, wish you luck on finding a solution. Back to top |
Thanks, it seems to be a hard task... I've posted questions about this in other forums but no satisfactory solution has come up so far.. I've also been trying unsuccessfully myself ...
Back to top |
my guess is that doing a job like this would involve real programming, that's what it sounds like to me. You'd have to program a module that did what you wanted, and then somehow a macro or something would have to interact with the program module.
That's just a guess. It would be interesting to see how OpenOffice.org handled this type of issue, I was looking into some stuff for that recently and it turned out to be much easier than I thought it would be. But I imagine you want this to run on standard office installs for some reason or other, corporate network or something. I suspect that if you just give up on the complicated way you're trying, and just have a standard table, and then have the macro handle the data in that standard table, it might work. If the table is as simple as you say, that might end up working, but I've never tried it. My guess is yes, the macro gets triggered by user action, then updates the data in the table each time a user action occurs. Back to top |
All times are GMT - 8 Hours |