Hi Marcel,
sorry, I don't know MS Word automation, could you please post a simple script sample that I can use to study the problem?
Thanks,
Roberto
Hi,
I studied the examples but could not find an answer to the next question:
VBA example: ActiveWindow.Panes(2).Close
I have an indexed object in Word such as .....Panes(2)..... How can I both reference the index but also getting the object back with the OLE_Execute() statement.
Is that done with the %TB_DISPATCH_PROPERTYPUTREF constant?
Kind regards<br /><br />Marcel
Hi Marcel,
sorry, I don't know MS Word automation, could you please post a simple script sample that I can use to study the problem?
Thanks,
Roberto
http://www.thinbasic.com
Hello Roberto,
What I'm doing is translating some Word VBA code into thinBasic and see what problems I encounter. I manage in addressing the objects and properties just like the examples but I run into a fence when I have to get an indexed object (collection).
Kind regards<br /><br />Marcel
Hi,
I did some more investigation and found that in this situation there is only one pane in Word. Therfore closing Pane(2) isn't possible and generates an error in VBA and so it will certainly do in thinBasic. In this example it not possible to check if Word is the problem or the thinBasic code.
I will create another example to test this adressing method.
Kind regards<br /><br />Marcel
This is a new version. It doesn't give a error but is also doesn't close the pane.
Kind regards<br /><br />Marcel
[code=thinbasic]
' if %wdPaneNone <> vRetVal then 'Check if there is a second pane and close it.
COM_Execute(pWdActWnd, "ActivePane", %TB_DISPATCH_PROPERTYGET, 0, 0, vRetVal)
PWdActPane = vRetVal
msgbox 0, "Activepane value: " & str$(vRetVal)
COM_Execute(pWdActPane, "Close", %TB_DISPATCH_METHOD, 0, 0, 0)
' end if
[/code]
this works but I dont know why the if doesnt enter, if enabled.
Home Desktop : Windows 7 - Intel Pentium (D) - 3.0 Ghz - 2GB - Geforce 6800GS
Home Laptop : WinXP Pro SP3 - Intel Centrino Duo - 1.73 Ghz - 2 GB - Intel GMA 950
Home Laptop : Windows 10 - Intel(R) Core(TM) i5-4210U CPU @ 1.70GHz, 2401 Mhz, 2 Core(s), 4 Logical Processor(s) - 4 GB - Intel HD 4400
Work Desktop : Windows 10 - Intel I7 - 4 Ghz - 8GB - Quadro Fx 370
Hello Abraxas,
Thanks for the help. I have an explanation why the if isn't working. The split screen I created isn't after all a SplitSpecial type. The next types are the types that are gonna closed.
[code=vb]wdPaneComments
wdPaneCurrentPageFooter
wdPaneCurrentPageHeader
wdPaneEndnoteContinuationNotice
wdPaneEndnoteContinuationSeparator
wdPaneEndnotes
wdPaneEndnoteSeparator
wdPaneEvenPagesFooter
wdPaneEvenPagesHeader
wdPaneFirstPageFooter
wdPaneFirstPageHeader
wdPaneFootnoteContinuationNotice
wdPaneFootnoteContinuationSeparator
wdPaneFootnotes
wdPaneFootnoteSeparator
wdPanePrimaryFooter
wdPanePrimaryHeader
wdPaneRevisions
[/code]
So only when Word is in one of the above states the if clause will be executed. To test the code inside the if construct Word has to be set in one of the above states.
If you change the "<>" in "=" and there is no SplitSpecial type active the Pane collection is empty and the close will generate an error if the pane(2).close or ActivePane.close command is used.
In the example I made there are 2 panes (splitted) and the active pane is closed by your solution. Running the same command again would generate an error. Therefore to test the code Word has to be first put into one of the SplitSpecial states and then the if code will be invoked.
That brings me to my original question. When I want to translate the next line:
[code=vb]ActiveWindow.Panes(2).Close[/code]
How do I address the .Panes(2) part. I think it has something to do with the %TB_DISPATCH_PROPERTYPUTREF constant. But I can't find information about it.
--- added --
Maybe I should explain that not the closing of the pane is the goal but the addressing of a member in a collection object.
Kind regards<br /><br />Marcel
Hi Marcel,
to get an indexed property you should use %TB_DISPATCH_PROPERTYGET and pass the indexes in the first n elements of parameters (vParam(1)=2) and the number of indexes in number of parameters (4th parameter of COM_Execute()) but again it does't work.
I'm not sure that Panes existing because if you choose close from file menu WORD close the document, instead I can remove the slipt from window menu.
Sorry but i'm not a MS WORD expert! So I'll need more time to study it.
Ciao,
Roberto
http://www.thinbasic.com
Hi Roberto,
Thanks, I will test it. I do not understand your sentence: "I'm not sure that Panes existing because if you choose close from file menu WORD close the document, instead I can remove the slipt from window menu." What do you mean with "instead I can remove the slipt ..."? Added: Oh I get it, you mean Split.
Take your time Roberto, I tinker with the info you gave.Sorry but i'm not a MS WORD expert! So I'll need more time to study it.
Kind regards<br /><br />Marcel
Hi,
I got it working but there is a macro recorded Word construction I do not understand quite right at the moment. I'm working for more than 10 years with Word and took the code Word produced always for granted. In this case I have my thoughts. :
Nevertheless I got the adressing working. It must be done with the item property, see the code. I also add an image of the panes().
Kind regards<br /><br />Marcel