Am Dienstag, den 03.01.2006, 17:53 -0500 schrieb Andrew Jensen: > OK, > > This is getting closer, but a couple of issues remain. > > I have my sub procedure that is called by the OnDocumentOpen broadcast > event. Using the suggested technique of > reading the last frame's title from the ActiveDesktop frames container > does indeed work.
I'm curious, how did you register the connection? Did you use the dialog and assigned the macro or did you do it out of a program? If maually: there is a difference bewteen having the event connected on document or application level... > However, as I put up before, the problem is that the procedure is called > twice. I am trying to find some way > to ignore the first call and act upon the second call. > > So far I have tried two things. Using a static variable in the > procedure, and using a global variable in the library. > 3 actually as just moving the variable out of the procedure did not work. > Here is the procedure now. > > const cBaseTitle = " - OpenOffice.org Base" > 'dim isInOnOpenAgain as boolean > global isInOnOpenAgain as boolean > > sub onOpenDocumentMain > dim df as variant > dim DBName as string > dim HideDBFrame as boolean > 'static isInOnOpenAgain as boolean > > df = Stardesktop.Frames > If RIGHT((df(df.count-1).title), LEN(cBaseTitle)) = cBaseTitle Then > if isInOnOpenAgain then > dbName = LEFT((df(df.count-1).title), LEN(df(df.count-1).title) > - LEN(cBaseTitle)) > isInOnOpenAgain = False > HideDBFrame = OpenDefaultForm( dbName ) > 'if HideDBFrame make it hidden somehow > else > isInOnOpenAgain = True > endif > End if > > end sub > > So - here is the problem and an oddity. If I have this library open in > the Basic editor when a base form is opened it works > as expected. The call to OpenDefaultForm happens just once. If it is not > open in the editor it fails and calls the function > twice. Any ideas on how to make the test variable isInOnOpenAgain act > like a static variable? That looks like a bug in OO.o 1.0.x where macros called from the commandline when starting the office where invoked twice. Should be fixed somewhere in the step to 1.1, but using a global boolean outside any sub did fix it for me. global hasrun as boolean sub importCSVfromCommandline(file as string) dim typ as string typ = left(FileNameoutofPath(file),2) msgbox file + " : " + typ importCSV(file, typ) end sub sub importCSV(file as string, typ as string) if hasrun = FALSE then hasrun =TRUE else exit sub end if ... This way it *did* work. > The oddity. While testing this libraries routines I happened to use drag > and frop to move an embedded form from one Base file to another. > Guess what happens. The onOpenDocumentMain procedure is called AND with > the library NOT in the editor it is > called only once??? For those that are interested, the dbName variable > is set to the target frame's Base name. Are you sure the library your macro lives in is loaded already when the event fires? The whole story sounds like this is a global space library, but if you need to use macros from let's say "Tools" you've got to load it before calling. But to be honest I don't know how to seperate the chicken and the egg here - how can OO.o be told to load a library at the start? Hope this helps somehow, Marc --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]