Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
jcampbell
Partner - Creator
Partner - Creator

Macro If Using Variable

I created a Macro recently which checks the row count of an object and if it is < 500 will export the data to Excel. Otherwise, it will present a message that the row count is too high.

I'd like to change this to use variables instead of having the max row count hard coded and I'm having difficultly getting this to work. I currently have a variable called "vMaxRowCount" with a value of 500. In my aforementioned Macro I have the following line:

ActiveDocument.Variables("vRowCount").SetContent CellRect.Height,true

So this stores the value of the row count of the object in the variable "vRowCount". I'd like to now change this line:

Current: If CellRect.Height > 500 Then


Desired: If ActiveDocument.Variables("vRowCount") > ActiveDocument.Variables("vMaxRowCount") Then


The "Desired" line does not work. I get the error "Object doesn't support this property or method". Can I use variables in a Macro in this way? Any feedback is much appreciated.


Thanks,

Josh

1 Solution

Accepted Solutions
Anonymous
Not applicable

Joshua,

Try this:

If ActiveDocument.Variables("vRowCount").GetContent.string > ActiveDocument.Variables("vMaxRowCount").GetContent.string Then

Regards,

Michael

View solution in original post

1 Reply
Anonymous
Not applicable

Joshua,

Try this:

If ActiveDocument.Variables("vRowCount").GetContent.string > ActiveDocument.Variables("vMaxRowCount").GetContent.string Then

Regards,

Michael