VBA script error

Posted on 2013-06-27
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
            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"
                If xlSheet.Range("printFoldColor").Text = "Color" Then
                    If twosided = True Then
                        wdDoc.ContentControls(i).Range.Text = "4/4"
                        wdDoc.ContentControls(i).Range.Text = "4/0"
                    End If
                    Exit For
                    If twosided = True Then
                        wdDoc.ContentControls(i).Range.Text = "1/1"
                        wdDoc.ContentControls(i).Range.Text = "1/0"
                    End If
                    Exit For
                End If
                Exit For
            End If
            Exit For
        End If

Open in new window

The error says "Automation error Call was rejected by callee."
Any ideas?
Question by:mjburgard
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 65

Expert Comment

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

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


Author Comment

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 ...

Accepted Solution

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.

Author Closing Comment

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.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying 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

In this article we want to have a look at the directory attributes which are used by Microsoft to store the so called Security Identifiers (SID). These SIDs plays an important role in delegating and granting permissions and in authentication of trus…
Well hello again!  Glad to see you've made it this far without giving up.  In this, the fourth installment of my popular series, I'm going to cover functions and subroutines, what they are, and why they are useful.  Just in case you stumbled onto th…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

717 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