Solved

VBA script error

Posted on 2013-06-27
4
238 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

770 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