Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-30-2015, 01:35 AM
Attila Attila is offline Return Value from DTpicker into DocVariable in Word Windows XP Return Value from DTpicker into DocVariable in Word Office 2010 64bit
Novice
Return Value from DTpicker into DocVariable in Word
 
Join Date: Jan 2015
Posts: 7
Attila is on a distinguished road
Default Return Value from DTpicker into DocVariable in Word

Hello there..

I have several Comboboxes and Textboxes in my UserForm all of them are returning correctly into my DocVariables.
The code I used to return Textbox Value to the Variable is:


ActiveDocument.Variable("var1") = Textbox1.value
I tried now to do the same with the DTPicker
ActiveDocument.Variable("var2") = DTPicker.value
But it returns either 00:00:00 or 30 0000 2015.
I tried to format the DTPicker with the code:
DTPicker = Format(DTPicker,"dd mmmm yyyy")
Also I tried to change the Variable to:
{DocVariable var2 \@ "dd mmmm yyyy"}
Each way didn't work. So please can somebody help me.
Reply With Quote
  #2  
Old 01-30-2015, 05:25 AM
gmayor's Avatar
gmayor gmayor is offline Return Value from DTpicker into DocVariable in Word Windows 7 64bit Return Value from DTpicker into DocVariable in Word Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Code:
 ActiveDocument.Variables("varDate").Value = Me.DTPicker1.Value
or
Code:
 ActiveDocument.Variables("varDate").Value = Format(Me.DTPicker1.Value, "Long Date")
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 01-30-2015, 05:51 AM
Attila Attila is offline Return Value from DTpicker into DocVariable in Word Windows XP Return Value from DTpicker into DocVariable in Word Office 2010 64bit
Novice
Return Value from DTpicker into DocVariable in Word
 
Join Date: Jan 2015
Posts: 7
Attila is on a distinguished road
Default

with your help i got now a date what looks like a date.
But it shows now "Saturday, 30. December 1899"
As I understood this means the DTPicker value is 0 means something doesn't work.
may you help me again?
Reply With Quote
  #4  
Old 01-30-2015, 06:06 AM
gmayor's Avatar
gmayor gmayor is offline Return Value from DTpicker into DocVariable in Word Windows 7 64bit Return Value from DTpicker into DocVariable in Word Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

I notice that your message header indicates Office 2010 64 bit. I have no idea to what extent the 64 bit version will work correctly with DTPicker (if at all).

Did you set the initial value of the picker e.g.
Code:
Me.DTPicker1.Value = Date
There's an alternative picker available from Trevor Eyre that will work when DTPicker is a problem You can find that here. Although intended for Excel, it needs only very minor mods to work in Word, and I use it in a couple of my own add-ins.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #5  
Old 01-30-2015, 06:23 AM
Attila Attila is offline Return Value from DTpicker into DocVariable in Word Windows XP Return Value from DTpicker into DocVariable in Word Office 2010 64bit
Novice
Return Value from DTpicker into DocVariable in Word
 
Join Date: Jan 2015
Posts: 7
Attila is on a distinguished road
Default

yes I initialized the date.
What is weird ist that in my document (whit several textboxes an comboboxes) where I actually need the datepicker it doesn't work. But when I Open a new blank document and make a userform with just a datepicker and a docvariable it works
only with the code:
activedocument.variables("var2").Value = DTPicker1.Value
Reply With Quote
  #6  
Old 01-30-2015, 06:57 AM
Attila Attila is offline Return Value from DTpicker into DocVariable in Word Windows XP Return Value from DTpicker into DocVariable in Word Office 2010 64bit
Novice
Return Value from DTpicker into DocVariable in Word
 
Join Date: Jan 2015
Posts: 7
Attila is on a distinguished road
Default

After a few researches I finally got the todays date shown as I want it. But when I run the userform and change the date it doesn't update in my docvariable.
But i have the code as above:
ActiveDocument.Variables("varDate").Value = Format(Me.DTPicker1.Value, "Long Date")
Does somebody know a solution that the date choosen in the userform is in my docvariable?
Reply With Quote
  #7  
Old 01-30-2015, 07:11 AM
gmayor's Avatar
gmayor gmayor is offline Return Value from DTpicker into DocVariable in Word Windows 7 64bit Return Value from DTpicker into DocVariable in Word Office 2010 32bit
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Most Word fields do not automatically update. Add code to update the field(s)

The example code in http://www.gmayor.com/installing_macro.htm will update all the fields in the document (including the docvariable fields). Call it from your macro.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #8  
Old 01-30-2015, 07:26 AM
Attila Attila is offline Return Value from DTpicker into DocVariable in Word Windows XP Return Value from DTpicker into DocVariable in Word Office 2010 64bit
Novice
Return Value from DTpicker into DocVariable in Word
 
Join Date: Jan 2015
Posts: 7
Attila is on a distinguished road
Default

thank you for your help. But I already have the code to update all.
I now figured out that when I do "me.hide" the userform it works but it doesn't work when I do "unload me". I would prefer to have the "unload me" solution.
Do you know why it makes a difference between unload and hide?
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
DocProperty vs DocVariable ChrisBrewster Word VBA 1 02-07-2014 02:09 PM
DocVariable formatting and the ability to truncate a string. MaxInCO Word 1 12-18-2013 05:35 PM
Return Value from DTpicker into DocVariable in Word Calculate the coordinates of a DocVariable, Bookmark or paragraph. MaxInCO Word VBA 5 12-11-2013 03:28 PM
Return Value from DTpicker into DocVariable in Word DTPicker date formatting Andy2011 Word VBA 1 08-24-2012 02:45 PM
Return Value from DTpicker into DocVariable in Word DOCVARIABLE copy paste special cyndor Word 2 04-06-2012 03:57 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:57 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft