Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 10-13-2011, 04:44 AM
SaneMan SaneMan is offline How to link userform to another word document Windows 98/ME How to link userform to another word document Office 2003
Novice
How to link userform to another word document
 
Join Date: Jan 2011
Posts: 20
SaneMan is on a distinguished road
Default How to link userform to another word document

Hello



I have created a userform which will be used by various people. The userform contains fields which the user will fill in to create DocVariables which are contained in the word document behind the form. This all works fine.

However, I want the userform to populate various letters. The user will click on a command button which will find and open various letter templates which are populated with DocVariable fields.

The problem is, when the userform opens these letters the docvariables are not populating and I get the 'Error! No document variable supplied.' message.

I somehow need to get the letter that the userform opens to look at the userform variables and populate the active links with those variables, but try as I might I have no been able to figure out how to do it.

Any help would be much appreciated.

Thanks.
Reply With Quote
  #2  
Old 10-13-2011, 06:28 PM
macropod's Avatar
macropod macropod is offline How to link userform to another word document Windows 7 64bit How to link userform to another word document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi SaneMan,

Without seeing a document with your userform code, plus a sample target document, it's hard to say what the issue is. There are various possibilities.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 10-14-2011, 01:42 AM
SaneMan SaneMan is offline How to link userform to another word document Windows 98/ME How to link userform to another word document Office 2003
Novice
How to link userform to another word document
 
Join Date: Jan 2011
Posts: 20
SaneMan is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Hi SaneMan,

Without seeing a document with your userform code, plus a sample target document, it's hard to say what the issue is. There are various possibilities.
Thanks macropod. I've attached an example of the form here and its accompanying letter.

If you open the form and go to the second tab you can input some details and then the letter is in the third tab. If you want to get behind the form to look at the macros you click on the big button on the first tab.

I've set the letter to open from My Documents so you might need to change the route address if you want to try it out. Really struggling to get the letter it opens to populate from the variables from the form!

Thanks so much for the help.
Attached Files
File Type: doc User Form.doc (482.5 KB, 44 views)
File Type: doc Letter MF.doc (53.5 KB, 27 views)
Reply With Quote
  #4  
Old 10-14-2011, 03:09 AM
macropod's Avatar
macropod macropod is offline How to link userform to another word document Windows 7 64bit How to link userform to another word document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi SaneMan,

If you run the following code, you'll see which variables do/don't exist. It's a bit hard to populate those that don't ...
Code:
Sub Test()
Dim i
With ActiveDocument
  For i = 1 To .Variables.Count
    MsgBox .Variables(i).Name & vbCr & .Variables(i).Value
  Next
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 10-14-2011, 03:21 AM
SaneMan SaneMan is offline How to link userform to another word document Windows 98/ME How to link userform to another word document Office 2003
Novice
How to link userform to another word document
 
Join Date: Jan 2011
Posts: 20
SaneMan is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
Hi SaneMan,

If you run the following code, you'll see which variables do/don't exist. It's a bit hard to populate those that don't ...
Code:
Sub Test()
Dim i
With ActiveDocument
  For i = 1 To .Variables.Count
    MsgBox .Variables(i).Name & vbCr & .Variables(i).Value
  Next
End With
End Sub
Hi macropod

Thanks for that. I tested the Macro on the userform and all the variables that I have entered appear to be populating.

If I put a letter into the actual document behind the userform then the variables populate fine. The problem appears to occur when the form opens the letter up from another location. It opens it up fine but there doesn't seem to be a link between the userform and the new document that would communicate with it and input the variables into the DocVariable references in the letter.

I feel like there must be an obvious and simple way of fixing this but I've ran out of ideas. I assume there must be some code you can put into the macros in the user form so that when the form opens up the new letter it has a direct link to it and refreshes the variables in the letter with the variables that have already been populated on the form.

Thanks for your help on this.
Reply With Quote
  #6  
Old 10-14-2011, 05:12 AM
macropod's Avatar
macropod macropod is offline How to link userform to another word document Windows 7 64bit How to link userform to another word document Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi SaneMan,

If you compared the output from the macro I posted to the DocVariables you're trying to work with, you'd see that none of them exist! It's not a matter of what's on the userform, it's a matter of what DocVariables exit in the underlying document. Whatever document you're running the code against needs to have the DocVariables in it too - and, presumably, you'll need to create them if they don't.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word doc bug when closing from userform command button click macro Joe Patrick Word 1 07-05-2011 08:53 PM
How to link userform to another word document Setting focus to specific word document from UserForm SaneMan Word VBA 5 04-01-2011 03:11 PM
How to link userform to another word document Checkbox on Userform result in Text in Word Dolfie_twee Word VBA 1 06-22-2010 07:54 AM
[Word 2003] Macro's and a UserForm xanuex Word VBA 0 10-19-2009 05:42 AM
How to link text from one document to another nospamforyou Word 0 10-09-2008 09:14 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:36 PM.


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