Solved

VBA script error

Posted on 2013-06-27
4
239 Views
Last Modified: 2013-07-03
When I run the following, I get an error only when twosided = false.  It runs normally when twosided = true.
If xlSheet.Range("PFNumSides") = "2" Then
            twosided = True
        Else
            twosided = False
        End If
        
    'Page cover - ink
    For i = 1 To wdDoc.ContentControls.Count
        If wdDoc.ContentControls(i).Title = "inks1" Then
            If xlSheet.Range("PrintFoldColor").Text = "Color/Black&White" Then
                wdDoc.ContentControls(i).Range.Text = "4/1"
            Else
                If xlSheet.Range("printFoldColor").Text = "Color" Then
                    If twosided = True Then
                        wdDoc.ContentControls(i).Range.Text = "4/4"
                    Else
                        wdDoc.ContentControls(i).Range.Text = "4/0"
                    End If
                    Exit For
                Else
                    If twosided = True Then
                        wdDoc.ContentControls(i).Range.Text = "1/1"
                    Else
                        wdDoc.ContentControls(i).Range.Text = "1/0"
                    End If
                    Exit For
                End If
                Exit For
            End If
            Exit For
        End If
    Next

Open in new window

The error says "Automation error Call was rejected by callee."
Any ideas?
0
Comment
Question by:mjburgard
  • 3
4 Comments
 
LVL 65

Expert Comment

by:RobSampson
ID: 39283385
What type of object is that content control?  Maybe it's trying to interpret it literally as a division by zero.

Try
wdDoc.ContentControls(i).Range.Text = CStr("4/0")

Rob.
0
 
LVL 1

Author Comment

by:mjburgard
ID: 39284513
Thanks rob, but that is going into a microsoft word document as text. - and last night it mysteriously started working - I have no explanations at this point.

I am going to mark this as completed - but ...
0
 
LVL 1

Accepted Solution

by:
mjburgard earned 0 total points
ID: 39284524
Last night - the macro suddenly started working - I have no explanation as to why - just that it has.

Nothing changed, no code was changed, The only possibility is that a new instance of excel was opened - but I am not even sure about that as I had opened and closed the spreadsheet multiple times before.

Marking this one finished, but with no understanding of why it was happening in the first place.
0
 
LVL 1

Author Closing Comment

by:mjburgard
ID: 39295993
If you read my previous comment, you will see that it just started working last night.

I still have no idea why, but I no longer have a problem if it is working.
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hello again, all.  For those of you that have been following along, you'll know that this is my third article on this topic (though it is not Part III).  This article is sort of remedial, and probably the topic with which I should have started the s…
Introduction During my participation as a VBScript contributor at Experts Exchange, one of the most common questions I come across is this: "I have a script that runs against only one computer. How can I make it run against a list of computers in …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question