FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Word (Selection.Find....)

 
Post new topic   Reply to topic     Forum Index -> Juno
View previous topic :: View next topic  
Author Message
gekkonier



Joined: 27 Mar 2007
Posts: 28

PostPosted: Thu Mar 19, 2009 11:01 am    Post subject: Word (Selection.Find....) Reply with quote

Hi all!

First of all, thank you for juno!!!

I would like to translate a program that I use at work from purepasic (using a disphelper derivate library) with a d version using juno.

I have this parts here in purebasic:
Code:
Procedure word_open(filename.s)
   Global oWord.l = dhCreateObject("Word.Application")
   dhPutValue (oWord, "Visible = %b", #True)
   path.s = GetCurrentDirectory() + filename
   dhCallMethod (oWord, "Documents.Add(%s)", @path)
   dhCallMethod    (oWord,"Selection.Goto = %u",0,0,0)
EndProcedure

Procedure word_release()
   dhReleaseObject (oWord)
   oWord = 0
EndProcedure

Procedure word_replace(such.s, ersetzt.s)
   wdReplaceAll.l = 2
   dhPutValue      (oWord,"Selection.Find.Forward = %b",#True)
   dhPutValue      (oWord,"Selection.Find.MatchWholeWord = %b",#True)
   dhPutValue      (oWord,"Selection.Find.Text = %s",@such)
   dhPutValue      (oWord,"Selection.Find.Replacement.Text = %s",@ersetzt)
   dhCallMethod    (oWord,"Selection.Find.Execute(%m,%m,%m,%m,%m,%m,%m,%m,%m,%m,%u)",wdReplaceAll)
EndProcedure


I just started to write a testprogram, and this is what I got now - it opens a given document under usage of a dot-file. Now I want to replace all occurrences of a string with another.
I stumbled about the Selection.Find.Forward etc. parts. How can I use them with juno?

Code:
pragma(lib, "juno.lib");

import juno.com.core;
import juno.com.client;
import std.path;

void main(char[][] args) {
   char[] basepath = getDirName(args[0]);
   char[] path =  basepath ~ "\\cdhuelle.dot";
   scope word = new DispatchObject("Word.Application");
   scope docs = word.get("Documents");
   word.set("Visible", true);
   docs.call("Add", path);
   scope selection = word.get("Selection");
}
Back to top
View user's profile Send private message
jicman



Joined: 22 Dec 2004
Posts: 298
Location: Rochester, NY

PostPosted: Thu Mar 19, 2009 8:47 pm    Post subject: Reply with quote

You need to keep assigning each class to a value. So, to get to find you need to use selection.get("find") and assign that to a variable, then use that variable to get to Forward, etc... So this,

Code:
   dhPutValue      (oWord,"Selection.Find.Forward = %b",#True)


should look like this,

Code:

   scope selection = word.get("Selection");
   scope find = selection.get("find");
   scope ffrd= find.set("Forward", true);


You may also have to use DispatchObject on some of these. Such as,
Code:

scope wb = new DispatchObject(xl.get("WorkBooks"));


So, you need to play around with some of these.

I hope this helps,

jic
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> Juno All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group