LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Copy from Excel to bookmarks in Word

Hello
I'm using the macro below, but I can't get it working the way I
like it. (A macro I found on the net) The first problem happens while
paste in the name bookmark, there it paste the Excel cell with text and
not only the text. Why?
And why do I sometimes have to start the macro 2 times before the word
file will open?

Sub TilMerke()
Dim appWrd As Object
Dim objDoc As Object
Dim FilePath As String
Dim FileName As String
Dim LastRow As Long
Dim Prompt As String
Dim Title As String
'Turn some stuff off while the macro is running
Application.ScreenUpdating = False
Application.EnableEvents = False
Application.DisplayAlerts = False
'Assign the Word file path and name to variables
FilePath = ThisWorkbook.Path
FileName = "WorkWithExcel.doc"
'Determine the last row of data for our loop
LastRow = Sheets("Sykemeldinger").Range("A65536").End(xlUp). Row
'Copy the data from Thisworkbook
ThisWorkbook.Sheets("Sykemeldinger").Range("aa17") .Copy
'Create an instance of Word for us to use
Set appWrd = CreateObject("Word.Application")
'Open our specified Word file, On Error is used in case the file
is not there
On Error Resume Next
Set objDoc = appWrd.Documents.Open("C:\test\soknad2.doc")
On Error GoTo 0
'Tell Word to goto the bookmark assigned to the variable
BookMarkRange
appWrd.Selection.Goto What:=wdGoToBookmark, Name:="kommune"
'Paste into Word
appWrd.Selection.Paste
'Copy the data from Thisworkbook
ThisWorkbook.Sheets("Sykemeldinger").Range("t17"). Copy
'Tell Word to goto the bookmark assigned to the variable
BookMarkRange
appWrd.Selection.Goto What:=wdGoToBookmark, Name:="navn"
'Paste into Word
appWrd.Selection.Paste
'Copy the data from Thisworkbook
ThisWorkbook.Sheets("Sykemeldinger").Range("w17"). Copy
'Tell Word to goto the bookmark assigned to the variable
BookMarkRange
appWrd.Selection.Goto What:=wdGoToBookmark, Name:="Fnummer"
'Paste into Word
appWrd.Selection.Paste
'Make our Word session visible
appWrd.Visible = True
'Clean up
Set appWrd = Nothing
Set objDoc = Nothing
End Sub

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
simple? Word Bookmarks link to Excel JFamilo[_8_] Excel Programming 3 July 20th 05 11:35 PM
Excel and Word Bookmarks JFamilo[_7_] Excel Programming 1 July 14th 05 05:13 AM
exporting Excel data to Word using Bookmarks Dave Kilroy Excel Programming 0 May 19th 05 05:33 PM
VBA, Bookmarks, Word and Excel... help please! [email protected] Excel Programming 2 February 13th 05 09:03 PM
Using Word Bookmarks to read Text Charles Excel Programming 2 February 12th 04 03:40 PM


All times are GMT +1. The time now is 09:01 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"