OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 23-11-2011, 19:16
Soundbytes
Guest
 
Posts: n/a
Default DataField.DataType code

For my current project I need to store a couple of values safely within the document.
After a little research I found that the Document.DataFields collection might be suitable for the task.
I was able to make sense out of most of the parameters that are interesting to me. However I haven't been able to find out how the DataField.DataType
is encoded.
From what I have gathered so far it seems like the datatype 0 stands for String while 1 means Double.
Am I right in assuming that? Are there any further numbers for Integer, Boolean and so on?
I have not been able to find a book or ressource that covers the topic. Is there any?
Thanks!
Reply With Quote
  #2  
Old 24-11-2011, 10:02
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,790
Blog Entries: 12
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Document Properties

Might I suggest that you use Document Properties instead. I find it to be a more reliable way to store data in the document. Here is a little example for the help file:
Code:
Sub Test() 
 Const MyMacroName As String = "MyTestMacro" 
 With ActiveDocument 
  .Properties(MyMacroName, 1) = "My String 1" ' String 
  .Properties(MyMacroName, 2) = 1 ' Integer 
  .Properties(MyMacroName, 3) = Atn(1) * 4 ' Double 
  MsgBox .Properties(MyMacroName, 1) 
  MsgBox .Properties(MyMacroName, 2) 
 MsgBox .Properties(MyMacroName, 3) 
 End With 
End Sub
Hope that helps,

-Shelby
Reply With Quote
  #3  
Old 07-12-2011, 15:10
Soundbytes
Guest
 
Posts: n/a
Default

Thanks for the answer.

Can you please give some detail why you find the DataFields collection unreliable?
What would be the benefit of using Document Properties instead?

I have now played around with Documents.DataFields a bit and until now it seems like it works as expected. (I still have to find out what the datatype values mean though.)

Andreas
Reply With Quote
  #4  
Old 07-12-2011, 21:20
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,790
Blog Entries: 12
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default DataFields

I have one Macro that uses DataFields a lot, and every so often something seems to get crossed and you have to reboot in order to get things working it. It could just be my macro, but I have yet to find the cause, except that it does seem to be DataFields related.

The biggest advantage to Document.Properties is that they are hidden to the user, the user cannot change or modify them, they can the DataFields.

Go ahead and use DataFields, if you run into problems let me know, I would love to find the solution to my issue.

-Shelby
Reply With Quote
  #5  
Old 09-12-2011, 09:46
Craig Tucker
Guest
 
Posts: n/a
Default Shape.Properties

Hi Shelby,
Along the same lines as storing values on a document in properties...
Do you know if there is a way to store custom hidden values on a shape level?
Shape.Properties cannot be used like a method.
Thanks much,
Craig
Reply With Quote
  #6  
Old 10-12-2011, 01:18
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,790
Blog Entries: 12
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Shape.Properties

I do not know of a way to do this on a shape level. Agreed, it would be very nice!

-Shelby
Reply With Quote
  #7  
Old 12-12-2011, 11:17
jemmyell jemmyell is offline
Senior Member
 
Join Date: Jan 2005
Location: Orange County, California, USA, Earth, Solar System, Milky Way Galaxy
Posts: 157
Default

Hi,

I use shape properties all the time. Just look at the help item for the syntax. You can store invisible properties in the Document, Page , Layer and Shape objects.

-James
__________________
-James Leonard
CNC Inlay Guy - www.CorelDRAWCadCam.com
Reply With Quote
  #8  
Old 13-12-2011, 07:21
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,790
Blog Entries: 12
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Shape.Properties

Sure enough this does work on the shape level. Wonderful! Sorry for the misinformation earlier. And thanks for correcting this James.
Reply With Quote
  #9  
Old 21-12-2011, 12:43
Craig Tucker
Guest
 
Posts: n/a
Default Shape.Properties

Very Nice! Thanks James...
Reply With Quote
  #10  
Old 21-12-2012, 04:44
FaneDuru FaneDuru is offline
Member
 
Join Date: May 2012
Posts: 35
Default

Quote:
Originally Posted by shelbym View Post
Might I suggest that you use Document Properties instead. I find it to be a more reliable way to store data in the document. Here is a little example for the help file:
Code:
Sub Test() 
 Const MyMacroName As String = "MyTestMacro" 
 With ActiveDocument 
  .Properties(MyMacroName, 1) = "My String 1" ' String 
  .Properties(MyMacroName, 2) = 1 ' Integer 
  .Properties(MyMacroName, 3) = Atn(1) * 4 ' Double 
  MsgBox .Properties(MyMacroName, 1) 
  MsgBox .Properties(MyMacroName, 2) 
 MsgBox .Properties(MyMacroName, 3) 
 End With 
End Sub
Hope that helps,

-Shelby
I know this is an old thread but I would like to clarify this issue...

In my case all properties defined in this way (for document or shape) are valid only for the present session when document is open. THEY CAN NOT BE SAVED WITH THE DOCUMENT.

Is there a trick/setting to make them to be saved with the document?
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
help correct code buga Macros/Add-ons 1 24-10-2011 15:34
Please revise my code beczukdavid Code Critique 3 02-07-2009 00:15
[useful code] wOxxOm CorelDRAW/Corel DESIGNER VBA 0 19-12-2007 15:00
[useful code] sortDelimitedText wOxxOm CorelDRAW/Corel DESIGNER VBA 0 19-12-2007 14:51
v11 code in v13 diwin CorelDRAW/Corel DESIGNER VBA 5 26-06-2007 18:43


All times are GMT -5. The time now is 10:50.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com