|
From: Carlos Paulino on 11 Jul 2008 12:58 Hi to all I have developed a system in Delphi and want to print into Word some information. I have created the field in Delphi that will print in word (DOCVARIABLE varname, IF{DOCVARIABLE varname}=" " "" ) but I keep having the message "Error! No document variable supplied." when no data is in Delphi database field. It works when there is data. Can any one out there help me in building the intructions to avoid the message mentioned above when the field is blank? Thanks for your valuable help. -- CP
From: Jean-Guy Marcil on 11 Jul 2008 15:25 "Carlos Paulino" wrote: > Hi to all > I have developed a system in Delphi and want to print into Word some > information. I have created the field in Delphi that will print in word > (DOCVARIABLE varname, IF{DOCVARIABLE varname}=" " "" ) but I keep having the > message "Error! No document variable supplied." when no data is in Delphi > database field. It works when there is data. Can any one out there help me in > building the intructions to avoid the message mentioned above when the field > is blank? If you create a DOCVARIABLE and then set it to "", you are actually deleting it. So any further reference to that DOCVARIABLE will generate an error message.
From: Carlos Paulino on 11 Jul 2008 17:14 Jean-Guy: What then could the right instructions not to get the error message. Will appreciate your help on this issue. -- CP "Jean-Guy Marcil" wrote: > "Carlos Paulino" wrote: > > > Hi to all > > I have developed a system in Delphi and want to print into Word some > > information. I have created the field in Delphi that will print in word > > (DOCVARIABLE varname, IF{DOCVARIABLE varname}=" " "" ) but I keep having the > > message "Error! No document variable supplied." when no data is in Delphi > > database field. It works when there is data. Can any one out there help me in > > building the intructions to avoid the message mentioned above when the field > > is blank? > > If you create a DOCVARIABLE and then set it to "", you are actually deleting > it. So any further reference to that DOCVARIABLE will generate an error > message. >
From: Doug Robbins - Word MVP on 13 Jul 2008 04:08 If there is not data, set the .Value of the variable to " " -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP "Carlos Paulino" <cppaulino(a)gmail.com> wrote in message news:B60DF0FB-A78A-4DAC-B4AB-7951ACA147E8(a)microsoft.com... > Jean-Guy: > What then could the right instructions not to get the error message. Will > appreciate your help on this issue. > -- > CP > > > "Jean-Guy Marcil" wrote: > >> "Carlos Paulino" wrote: >> >> > Hi to all >> > I have developed a system in Delphi and want to print into Word some >> > information. I have created the field in Delphi that will print in word >> > (DOCVARIABLE varname, IF{DOCVARIABLE varname}=" " "" ) but I keep >> > having the >> > message "Error! No document variable supplied." when no data is in >> > Delphi >> > database field. It works when there is data. Can any one out there help >> > me in >> > building the intructions to avoid the message mentioned above when the >> > field >> > is blank? >> >> If you create a DOCVARIABLE and then set it to "", you are actually >> deleting >> it. So any further reference to that DOCVARIABLE will generate an error >> message. >>
From: Jean-Guy Marcil on 14 Jul 2008 08:24
"Carlos Paulino" wrote: > Jean-Guy: > What then could the right instructions not to get the error message. Will > appreciate your help on this issue. You have to cycle through the Document Variable collection, if the one you are looking far is not there, you have to create it. For example, in VBA: Dim i As Long Dim varname As String Dim boolCreateVar As Boolean varname = "MyVariable" boolCreateVar = True If ActiveDocument.Variables.Count > 0 Then For i = 1 To ActiveDocument.Variables.Count If ActiveDocument.Variables(i).Name = varname Then boolCreateVar = False Exit For End If Next End If If boolCreateVar Then ActiveDocument.Variables.Add varname, "SomeValue" End If 'Do what you have to do with that variable here But, as Doug suggested, it is by far easier to make sure that variables always have at least a space as a value, then you know they always exist. This is easily done since variables can only be created/modified via code. |