Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Guys,
A question related to Macro.. I have a vStichtag as a variable and for example is assigned as a date '31.12.2008'
By selecting this date I select all the values which are '31.12.2008'<=Table.BEGDA and '31.12.2008' >=Table.ENDDA
I resignate the Macro selectstichtag1 to Vstichtag in the Properties of the documents-> macros->Variable
I set a variable l_tabellen_stichtag1_gesteuert in skript to all the tables which I want to loop in the macro according to the variable '31.12.2008'
ActiveDocument.Fields(fieldname).Unlock at this position I am getting a error..
can u pls help and tell whether the code is correct?
sub SelectStichtag
set v = ActiveDocument.Variables("vStichtag")
x = "<=" & v.GetContent.String
SelectAndLock "Table1.BEGDA",x
SelectAndLock "Table2.BEGDA",x
SelectAndLock "Table3.BEGDA",x
SelectAndLock "Table4.BEGDA",x
SelectAndLock "Table5.BEGDA",x
SelectAndLock "Table6.BEGDA",x
SelectAndLock "Table7.BEGDA",x
SelectAndLock "Table8.BEGDA",x
SelectAndLock "Table9.BEGDA",x
SelectAndLock "Table10.BEGDA",x
SelectAndLock "Table11.BEGDA",x
SelectAndLock "Table12.BEGDA",x
x = ">=" & v.GetContent.String
SelectAndLock "Table1.ENDDA",x
SelectAndLock "Table2.ENDDA",x
SelectAndLock "Table3.ENDDA",x
SelectAndLock "Table4.ENDDA",x
SelectAndLock "Table5.ENDDA",x
SelectAndLock "Table6.ENDDA",x
SelectAndLock "Table7.ENDDA",x
SelectAndLock "Table8.ENDDA",x
SelectAndLock "Table9.ENDDA",x
SelectAndLock "Table10.ENDDA",x
SelectAndLock "Table11.ENDDA",x
SelectAndLock "Table12.ENDDA",x
end sub
sub selectStichtag1
dim i_tabellenliste, a_tabelle, i_tabelle, i_feld
dim i_selektion_begda, i_selektion_endda, i_stichtag
i_stichtag = ActiveDocument.Variables("vStichtag")_
.getContent.String
i_tabellenliste = ActiveDocument.Variables("l_tabellen_stichtag1_gesteuert")_
.getContent.String
a_tabelle = split(i_tabellenliste,",")
i_selektion_begda = "<=" & i_stichtag
i_selektion_endda = ">=" & i_stichtag
for each i_tabelle in a_tabelle
i_tabelle = trim(i_tabelle)
i_feld = i_tabelle & ".BEGDA"
call SelectAndLock (i_feld,i_selektion_begda)
i_feld = i_tabelle & ".ENDDA"
call SelectAndLock (i_feld,i_selektion_endda)
next
end sub
sub SelectAndLock (fieldname, selection)
ActiveDocument.Fields(fieldname).Unlock
ActiveDocument.Fields(fieldname).Clear
ActiveDocument.Fields(fieldname).Select selection,true,1
ActiveDocument.Fields(fieldname).Lock
end sub
Thanks in advance
sravan
Hi Sravan,
can you hear my brains working ? I'm almost getting a "Hirnkrampf" imagining what else it could be 😉
It would be very helpful to know the exact value of the ominous variable I_tabellen_stichtag1_gesteuert, perhaps I can see there what I can't think of now. Could you perhaps post it, I think it won't contain to much sensible data, does it?
Rgds,
Joachim