| | |
Accessing excel worksheet in a word document (VB macro).
![]() |
•
•
Join Date: Mar 2006
Posts: 2
Reputation:
Solved Threads: 0
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 can only activate the table for example like this: ActiveDocument.Fields(1).OLEFormat.Activate - this leads to the same result as double clicking on the table object...
... I know how to access MS Word tables, but the problem here is that I have to work with an Excel table.. I suppose only an Excel macro can access it and modify it... And if I write an excel macro to do so, how can I call it from my MS word macro script? Does solving of this problem involve OLE, DDE...? Maybe I should run the Excel application to modify the table and then close it.. so far I have no success in doing that.. this has to be implemented in a single MS word macro.
Thank you!
... I know how to access MS Word tables, but the problem here is that I have to work with an Excel table.. I suppose only an Excel macro can access it and modify it... And if I write an excel macro to do so, how can I call it from my MS word macro script? Does solving of this problem involve OLE, DDE...? Maybe I should run the Excel application to modify the table and then close it.. so far I have no success in doing that.. this has to be implemented in a single MS word macro.
Thank you!
Hi
Try this:
I am not sure about the sytax of the formula, but that will get you to the specified cell.
Regards
Try this:
Visual Basic 4 / 5 / 6 Syntax (Toggle Plain Text)
Dim tabl As Table Set tabl = ActiveDocument.Tables(1) tabl.Cell(1, 1).formula("xxx")
I am not sure about the sytax of the formula, but that will get you to the specified cell.
Regards
•
•
Join Date: Mar 2006
Posts: 2
Reputation:
Solved Threads: 0
Thank you! But this doesn't help in my case.
Maybe I haven't explained the situation right.
Here is another 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:
MsgBox ActiveDocument.Fields(1).OLEFormat.ProgID
The 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:
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..
Thanks again!
Maybe I haven't explained the situation right.
Here is another 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:
MsgBox ActiveDocument.Fields(1).OLEFormat.ProgID
The 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:
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..
Thanks again!
•
•
Join Date: Aug 2008
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
Thank you! But this doesn't help in my case.
Maybe I haven't explained the situation right.
Here is another 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:
MsgBox ActiveDocument.Fields(1).OLEFormat.ProgID
The 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:
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..
Thanks again!
Dear Sir,
I get the same problem, have some one get a solution ?
THanks
![]() |
Similar Threads
- MS word document automaticaly copies a duplicate one every time I open a word documen (Windows NT / 2000 / XP)
- How we open a ms word document file with php? (PHP)
- Extract MS Excel Data embedded in MS Word (Visual Basic 4 / 5 / 6)
- To read color highlighted text in word document from vb.net (VB.NET)
- How can we print an MS Word document from Java (Java)
- Picture file on a Word document (Windows NT / 2000 / XP)
Other Threads in the Visual Basic 4 / 5 / 6 Forum
- Previous Thread: ListView
- Next Thread: use progress bar on msgbox
| Thread Tools | Search this Thread |
* 6 429 2007 access activex add age application basic beginner birth bmp calculator cd cells.find click client code college component connection connectionproblemusingvb6usingoledb copy creat ctrl+f data database datareport date delete dissertations dissertationthesis dissertationtopic edit error excel excelmacro file filename form hardware header iamthwee image inboxinvb internetfiledownload keypress label listbox listview liveperson login looping machine microsoft movingranges number objectinsert open oracle password prime program prompt range-objects readfile reading record refresh remotesqlserverdatabase report save search sendbyte sites sort sql sql2008 sqlserver subroutine tags textbox time urldownloadtofile vb vb6 vb6.0 vba visual visualbasic visualbasic6 web window windows





