Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello,
how to have all the list of the variables of an application with its expression, without going through the menu of the variables
Create an empty Inputbox object and note the object reference.
Create this macro subroutine ...
sub ShowVars
rem ** Show name of all variables in document **
set vars = ActiveDocument.GetVariableDescriptions
set IB = ActiveDocument.GetSheetObject("IB01")
for i = 0 to vars.Count - 1
set v = vars.Item(i)
'msgbox(v.Name & "=" & v.RawValue)
'Add to InputBox object (IB01)
IB.AddVariable v.Name
next
end sub
Add a button to call this code
Create an empty Inputbox object and note the object reference.
Create this macro subroutine ...
sub ShowVars
rem ** Show name of all variables in document **
set vars = ActiveDocument.GetVariableDescriptions
set IB = ActiveDocument.GetSheetObject("IB01")
for i = 0 to vars.Count - 1
set v = vars.Item(i)
'msgbox(v.Name & "=" & v.RawValue)
'Add to InputBox object (IB01)
IB.AddVariable v.Name
next
end sub
Add a button to call this code
Thank ypu
Welcome
Arvid how to write the value in csv or text file ?
Souad try this
1. Create an input box
2. Click Add All to list all variables
3. Send to Excel
i used this script
sub ShowVars
rem ** Show name of all variables in document **
set vars = ActiveDocument.GetVariableDescriptions
set IB = ActiveDocument.GetSheetObject("IB01")
DIM fso, MyFile, strFile, strText
strFile="c:\temp\link.msgFile"
Set fso = CreateObject("Scripting.FileSystemObject")
for i = 0 to vars.Count - 1
set v = vars.Item(i)
'msgbox(v.Name & "=" & v.RawValue)
'Add to InputBox object (IB01)
link=v.Name &","&v.RawValue
If fso.FileExists(strFile) Then
Set MyFile = fso.OpenTextFile (strFile, 2, True)
Else
Set MyFile = fso.CreateTextFile(strFile)
End If
MyFile.WriteLine(link)
OpenFile()
MyFile.Close
next
end sub
FUNCTION OpenFile
set app = ActiveDocument.GetApplication
app.Launch "C:\temp\link.msgFile", "file path"
END FUNCTION
But i have always problem with this ligne
link= link=v.Name &","&v.RawValue
Please run the code which i had given above and make sure that reference of empty input box is correct
and let me know its working or not
I modified the script
sub ShowVars
rem ** Show name of all variables in document **
set vars = ActiveDocument.GetVariableDescriptions
DIM fso, MyFile, strFile, strText
strFile="C:\Prod\liste"
Set fso = CreateObject("Scripting.FileSystemObject")
for i = 0 to vars.Count - 1
set v = vars.Item(i)
'msgbox(v.Name & "=" & v.RawValue)
'Add to InputBox object (IB01)
link= v.Name &","&v.RawValue
If fso.FileExists(strFile) Then
Set MyFile = fso.OpenTextFile (strFile, 2, True)
Else
Set MyFile = fso.CreateTextFile(strFile)
End If
MyFile.WriteLine(link)
OpenFile()
MyFile.Close
next
end sub
FUNCTION OpenFile
set app = ActiveDocument.GetApplication
app.Launch "C:\Prod\liste", "file path"
END FUNCTION
the script executed but the file is empty
It is because of macro security issues