Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
How do you distinguish between "ranges" in Excel vs. "ranges" in Word when
controlling Word using Excel VBA? Or is this necessary? I ask because I'm getting a "Type Mismatch" error when trying to run VBA code in Excel that controls a Word document. I'm filling in a Word document form using Excel VBA and I'm trying to fill in a field without deleting the bookmark. The code for how to do this in Word VBA is provided at the following website http://www.word.mvps.org/FAQs/Macros...AtBookmark.htm but the problem I'm having is that the same code does not work in my Excel VBA routine. Below is a portion of my Excel VBA routine. I notice that when I type in my "Dim BMRange as R" that the editor comes up with TWO "Range"s, and TWO of everything to chose from...leading me to believe that the first one is an Excel Range and the second one a Word Range, etc... Dim Data As Range, cell As Range .... Set wrdDoc = wrdApp.Documents.Open(WordTemplatesPath & FormType & ".dot") With ActiveSheet Set Data = ActiveSheet.AutoFilter.Range.Columns(5) 'bookmarks column Set Data = Data.Offset(1, 0).Resize(Data.Rows.Count - 1, 1) Set Data = Data.SpecialCells(xlVisible) For Each cell In Data UpdateBookmark cell.Value, Range(cell.Value) Next .... end sub Sub UpdateBookmark(BookmarkToUpdate As String, TextToUse As String) Dim BMRange As Range Set BMRange = ActiveDocument.Bookmarks(BookmarkToUpdate).Range BMRange.Text = TextToUse ActiveDocument.Bookmarks.Add BookmarkToUpdate, BMRange End Sub Any help would be appreciated. Tony |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Controlling MS Word from VBA Excel | Excel Programming | |||
controlling ms word from vba excel | Excel Programming | |||
Controlling Word from Excel | Excel Programming | |||
Controlling Word from Excel | Excel Programming |