473,320 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Expression cannot be evaluated at this time.

A VB module uses the Word object model. Late bound objects. I'm
searching for hidden text. At a certain point, my code simply hangs. I
have error trapping in place, but no exceptions occur. But if I pause
the program and try to evaluate my range object (rng), to see what's up,
I get a message "Expression cannot be evaluated at this time." in the
immediate window.

With minor differences, the code I'm using is pasted from a working VB6
app. Ideas? Here's the code. Ignore the "config.AddItemNode" function,
it just is writing information to a structure so I can display it later.


Dim rng As Object
Dim bOK As Boolean
Dim sBuf As String

Dim bRet As Boolean

Const wdActiveEndPageNumber = 3
Const wdFirstCharacterLineNumber = 10

' moDoc is my document (word.application.activedocument)
For Each rng In moDoc.StoryRanges
Try
rng.TextRetrievalMode.IncludeHiddenText = True
Catch ex As Exception
log.LogErr(ex)
Exit For
End Try

With rng.Find
.ClearFormatting()
.Font.Hidden = True
.Text = ""
.wrap = wdFindContinue
bOK = .Execute

Do While bOK
sBuf = ""

' same code as in VB6... but not working here.
Try

' THIS IS WHERE IT KEEPS "STICKING",
' at the evaluation of rng.text

If (rng Is Nothing) Then
Else
If (rng.Text Is Nothing) Then
Else
sBuf = rng.Text
sBuf = StripString(sBuf)
End If
End If

Catch ex As Exception
log.LogErr(ex)
End Try

If (sBuf = Nothing) Then sBuf = ""

If sBuf.Length > 0 Then
' exclude paragraph marks
If sBuf.Length = 1 And Asc(sBuf) = 13 Then
' don't display as a line item
Else
Try
Dim itempath = config.AddItemNode(xpath,
"hidden", "")

config.AddItemNode(itempath, "Text", sBuf)
config.AddItemNode(itempath, "Location",
GetStoryTypeDesc(rng.storytype))
config.AddItemNode(itempath, "Page",
Convert.ToString(rng.Information(wdActiveEndPageNu mber)))
config.AddItemNode(itempath, "Line",
Convert.ToString(rng.Information(wdFirstCharacterL ineNumber)))
Catch ex As Exception
config.AddItemNode(xpath, "security error",
"Can't display details due to document security.")
Exit Do
End Try
End If
.wrap = wdFindStop
bOK = .Execute
End If

Loop
End With
Next rng
Nov 20 '05 #1
0 1338

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

23
by: Paul Rubin | last post by:
OK, I want to scan a file for lines matching a certain regexp. I'd like to use an assignment expression, like for line in file: if (g := re.match(pat, line)): croggle(g.group(1)) Since...
70
by: Roy Yao | last post by:
Does it mean "(sizeof(int))* (p)" or "sizeof( (int)(*p) )" ? According to my analysis, operator sizeof, (type) and * have the same precedence, and they combine from right to left. Then this...
3
by: João Santa Bárbara | last post by:
Hi all this message ( Expression cannot be evaluated at this time. ) apears when i in the debug window do this ?xdrMaster("field1") can some one help me .. JSB
2
by: lp | last post by:
While debugging an application, whenever i enter into a specific function, all watch values refering to this function get the error message: "Expression Cannot Be evaluated at this Time". The...
6
by: Suresh Jeevanandam | last post by:
Dear all, I read in "Python in a Nutshell" that when we have multiple assignments made on a single line, it is equivalent to have those many simple assignments and that the right side is evaluated...
12
by: paul | last post by:
Hi everyone, I'm debugging an FFT routine and it has thrown up a perplexing error which I cannot trace. Cannot anyone help? I've included the relevant code below with comments: rlft3(data_in1,...
21
by: Steven T. Hatton | last post by:
I'm trying to improve my formal understanding of C++. One significant part of that effort involves clarifying my understanding of the vocabulary used to describe the language. This is from the...
13
by: hn.ft.pris | last post by:
Hi: I have the following simple program: #include<iostream> using namespace std; int main(int argc, char* argv){ const double L = 1.234; const int T = static_cast<const int>(L); int arr;
32
by: silpau | last post by:
hi, i am a bit confused on expression evaluation order in expressions involving unary increment.decrement operators along with binary operators. For example in the following expression x...
5
by: Jeff Bean | last post by:
I need to compute a 64 bit file offset which will get passed to the _lseeki64 function. The inputs to the offset calculation are all unsigned shorts or unsigned longs. For example: unsigned...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.