473,378 Members | 1,639 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,378 software developers and data experts.

VBA coding - Automating Table and Figure Captions/References

rustaferd
I have created VBA code that will automatically generate Table and Figure captions in a Word document, but when I run the code that should automatically generate Table and Figure references, I get a run-time error '4198'.

I need help figuring out why this is occuring and how to fix it. I have the code I would be happy to post if there is anybody out there interested in taking a look and offering suggestions.
Dec 3 '07 #1
2 3002
kadghar
1,295 Expert 1GB
I have created VBA code that will automatically generate Table and Figure captions in a Word document, but when I run the code that should automatically generate Table and Figure references, I get a run-time error '4198'.

I need help figuring out why this is occuring and how to fix it. I have the code I would be happy to post if there is anybody out there interested in taking a look and offering suggestions.
have you debuged it with F8 to see exactly in what line is your error?
and, yes, i think that it'll be nice if you show us a part of the code.
Dec 3 '07 #2
have you debuged it with F8 to see exactly in what line is your error?
and, yes, i think that it'll be nice if you show us a part of the code.
Yes - I did debug with F8 and below shows the place where the error stops:

I can run the Table and figure captions and that works, but when it runs the table or figure references this is the error that pops up…
[IMG]clip_image002.jpg[/IMG]

When I select the Debug button this is what I get…
[IMG]clip_image003.jpg[/IMG]


Here is some of the actual code(I can post more if needed):
[code]Function GetCrossReference(Caption As String, ReferenceType As String) As Integer
Dim refs As Variant
Dim refID As Integer

refs = ActiveDocument.GetCrossReferenceItems(ReferenceTyp e)

For i = 1 To UBound(refs)
If Caption = refs(i) Then refID = i
Next

GetCrossReference = refID

End Function
Sub UpdateCrossReference(curRange As Range, ReferenceType As String)
If (curRange.Style <> "tablecaption") And (curRange.Style <> "figurecaption") And (curRange.Style <> "Caption") Then
'curRange.InsertCrossReference ReferenceType, wdEntireCaption, GetCrossReference(curRange.Text, ReferenceType), True, False, False, " "
Dim iRefID As Integer
iRefID = GetCrossReference(curRange.Text, ReferenceType)
curRange.InsertCrossReference ReferenceType, wdEntireCaption, iRefID, True, False
End If
End Sub[code]
Dec 4 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: matt | last post by:
I have this bit of code that opens a file, reads it line by line, and prints the filename into an image on screen, so i get a big list of images on the page. However I want it to output into a...
1
by: Beringer | last post by:
Hello, I figure this is a very basic issue but haven't figured out how to do it. I am trying to create a grid-like control to be the basis of a schedule (show appointments). What I want is a...
3
by: Daniel M | last post by:
I'm building a medium-scale data-entry web application, which involves creating data entry forms, record listings and detail screens for lots of database tables. Rather than designing a series...
2
by: awebguynow | last post by:
Most JS people have seen sorttable.js and similar implementations. I'm trying to do a SubSelect of an existing table, restricting values in a Column to spec. range. Rows manipulated through...
7
by: Johnny | last post by:
In MSIE table captions are displayed at the same size as content. But in Firefox the text displays at browser default, It also exceeds the width of the table and the excess is hidden if the table...
4
by: attachmatey | last post by:
Greetings: I'm looking for some help in automating (what I thought would be) a simple procedure in Internet Explorer. I'm trying to put the following operation under a button click in an MS...
19
by: auratius | last post by:
http://www.auratius.co.za/CSharpCodingStandards.html Complete CSharp Coding Standards 1. Naming Conventions and Styles 2. Coding Practices 3. Project Settings and Project Structure 4....
9
by: Neal | last post by:
http://www.brassattackofspringfield.com/gigs.html CSS at http://www.brassattackofspringfield.com/default.css Opera and IE render caption as desired. Firefox does not. Why? And is there a fix?
0
by: =?Utf-8?B?TWFyY2VlcG9v?= | last post by:
I'm a newbie using Visual Studio and Vb.Net. The vbscript below opens a Windows Explorer Search Window. The Windows Explorer Search Window has fields in which the user can insert: (i) a search...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.