OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

How to change DDE Link file and update links in Writer Doc

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
jeffbeagle
General User
General User


Joined: 07 Nov 2009
Posts: 5

PostPosted: Sat Nov 07, 2009 2:40 pm    Post subject: How to change DDE Link file and update links in Writer Doc Reply with quote

I am needing to programatically change the file name of a DDE Link (Link to Calc page) and update the links in the Write file.

Any assistance would be appreciated.
Back to top
View user's profile Send private message
probe1
Moderator
Moderator


Joined: 18 Aug 2004
Posts: 2560
Location: Chonburi Thailand Asia

PostPosted: Mon Nov 09, 2009 6:11 am    Post subject: Reply with quote

Welcome to the forum.


See this example:

MassMoveDDE
MassMoveDDE wrote:
Demonstrates access to DDE objects from a Calc spreadsheet within a writer document

Use case: if you move a Writer and the corresponding Calc from directoryAAA to directoryBBB, existing DDE links still point to the “old” data file. This code will change the PATH part (constant string used!)



Good luck!
_________________
Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs
Back to top
View user's profile Send private message Visit poster's website
jeffbeagle
General User
General User


Joined: 07 Nov 2009
Posts: 5

PostPosted: Mon Nov 09, 2009 5:19 pm    Post subject: Reply with quote

Thanks for the help, just what I needed!!

Next time in Germany I must buy you a bier!!!

Thanks again,

Jeff
Back to top
View user's profile Send private message
probe1
Moderator
Moderator


Joined: 18 Aug 2004
Posts: 2560
Location: Chonburi Thailand Asia

PostPosted: Tue Nov 10, 2009 8:40 am    Post subject: Reply with quote

jeffbeagle wrote:
Next time in Germany I must buy you a bier!!!
Laughing

Thanks for the offer, but ... next time you're in Germany ... I will be in Asia (retiering in 13 days Cool )
_________________
Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs
Back to top
View user's profile Send private message Visit poster's website
jeffbeagle
General User
General User


Joined: 07 Nov 2009
Posts: 5

PostPosted: Wed Nov 11, 2009 5:40 am    Post subject: Reply with quote

congratulations on the retirement.

I did run into one problem that you might be able to help me with before you head for Asia.

if tempTF.SupportsService("com.sun.star.text.fieldmaster.DDE" ) then

I get Basic Runtime Error Object Variable not set. I tried to set it but still gave me the error.

Thanks for any help with this.

Jeff [/img]
Back to top
View user's profile Send private message
probe1
Moderator
Moderator


Joined: 18 Aug 2004
Posts: 2560
Location: Chonburi Thailand Asia

PostPosted: Wed Nov 11, 2009 8:32 am    Post subject: Reply with quote

jeffbeagle wrote:
I get Basic Runtime Error Object Variable not set. I tried to set it but still gave me the error.[/img]


Could you show the code used?
I can't tell from this side of the screen ... what's going on...


Which OOo version? Which operating system? Which document format?
_________________
Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs
Back to top
View user's profile Send private message Visit poster's website
jeffbeagle
General User
General User


Joined: 07 Nov 2009
Posts: 5

PostPosted: Wed Nov 11, 2009 10:38 am    Post subject: Reply with quote

OpenOffice 3.1, Windows XP Pro, DDE Links in Write Doc that reference a CALC document.

Just testing your example code and get's to this line

if tempTF.SupportsService("com.sun.star.text.fieldmaster.DDE" ) then

and gives the error


' Example to change the PATH part of all
' DDE links of a OOo Writer document
' 2007-05-11
Sub writer_MassMoveDDE
' load library with help function
GlobalScope.BasicLibraries.LoadLibrary( "Tools" )
' get all text fields
TFM = ThisComponent.getTextFieldMasters()
' get array of names
aEN = TFM.getElementNames()
' get every textfield
for i = 0 to UBound( aEN() )
xTF = TFM.getByName( aEN( i ) )
' check if it is a DDE
if tempTF.SupportsService("com.sun.star.text.fieldmaster.DDE" ) then
' get the filename
xFN = FileNameOutOfPath( tempTF.DDECommandFile , "\" )
' now compose and set new link target
xTF.DDECommandFile = "D:\Abrechnung\A1\"& xFN
end if
next
End sub
Back to top
View user's profile Send private message
probe1
Moderator
Moderator


Joined: 18 Aug 2004
Posts: 2560
Location: Chonburi Thailand Asia

PostPosted: Thu Nov 12, 2009 12:03 am    Post subject: Reply with quote

Ah - I see ...

There are three occurances of tempTF: please change to xTF
(typo? ... have to correct the coding; thanks!)

Code:
' Example to change the PATH part of all
' DDE links of a OOo Writer document
' 2007-05-11
' 2009-11-12  tempTF=>xTF   typo corrected
' ooo.91098
Sub writer_MassMoveDDE
' load library with help function
GlobalScope.BasicLibraries.LoadLibrary( "Tools" )
' get all text fields
TFM = ThisComponent.getTextFieldMasters()
' get array of names
aEN = TFM.getElementNames()
' get every textfield
for i = 0 to UBound( aEN() )
   xTF = TFM.getByName( aEN( i ) )
   ' check if it is a DDE
   if xTF.SupportsService("com.sun.star.text.fieldmaster.DDE" ) then
      ' get the filename
      xFN = FileNameOutOfPath( xTF.DDECommandFile , "\" )
      ' now compose and set new link target
      xTF.DDECommandFile = "D:\Abrechnung\A1\"& xFN
   end if

next
End sub

Does it work for you?
_________________
Cheers
Winfried
My Macros
DateTime2 extension: insert date, time or timestamp, formatted to your needs
Back to top
View user's profile Send private message Visit poster's website
jeffbeagle
General User
General User


Joined: 07 Nov 2009
Posts: 5

PostPosted: Thu Nov 12, 2009 5:51 am    Post subject: Reply with quote

http://www.facebook.com/photo.php?pid=30408166&id=1222465288

Not sure you can view this image.

It resolves the error, but it skips the DDE Link as shown in the image.

If you cannot see it, PM me with your email and I will send via email attachment.

Thanks,

Jeff
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 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