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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I met Paul Devereux (@pdevereux) today when I responded to his tweet asking “Anybody know how to automate adding files from disk to a folder in #outlook  ?”.  I replied back and told Paul that using automation, in this case scripting, to add files t…
This script will sweep a range of IP addresses (class c only, and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

867 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now