Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 21
Default Word from Excel

I'm using excel to open a preformatted word document from
a hyperlink and adding data from the excel record using
bookmarks. I want the word document to be saved according
to the bookmark value. I can't seem to be able to get the
last bit to work. Also everynow and then the code stops
because it can't find the bookmark and the only apparent
round this to get it working again is by logging off and
on again. The code I'm using is

Dim WordObj As Object
Set WordObj = CreateObject("Word.Basic")
Selection.Hyperlinks(1).Follow NewWindow:=True,
AddHistory:=True
Application.WindowState = xlMaximized
With WordObj
.EditBookmark "txtNo", 0, 0, 0, 1
.Insert txtNo.Value
End With

Any suggestions much appreciated
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Word from Excel

Not tested, but try to trap it

Dim WordObj As Object

On Error Resum Next
Set WordObj = CreateObject("Word.Basic")
On Error Goto 0
If WordObj Is Nothing Then
Msgbox "Bookmark not found"
Else
Selection.Hyperlinks(1).Follow NewWindow:=True,
AddHistory:=True
Application.WindowState = xlMaximized
With WordObj
.EditBookmark "txtNo", 0, 0, 0, 1
.Insert txtNo.Value
End With
End If

--

HTH

RP

"Simon" wrote in message
...
I'm using excel to open a preformatted word document from
a hyperlink and adding data from the excel record using
bookmarks. I want the word document to be saved according
to the bookmark value. I can't seem to be able to get the
last bit to work. Also everynow and then the code stops
because it can't find the bookmark and the only apparent
round this to get it working again is by logging off and
on again. The code I'm using is

Dim WordObj As Object
Set WordObj = CreateObject("Word.Basic")
Selection.Hyperlinks(1).Follow NewWindow:=True,
AddHistory:=True
Application.WindowState = xlMaximized
With WordObj
.EditBookmark "txtNo", 0, 0, 0, 1
.Insert txtNo.Value
End With

Any suggestions much appreciated



Reply
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
Need Excel count of 1 word if found in multi-word cells of column Function_Challenged Excel Worksheet Functions 1 August 27th 09 12:08 AM
excel object linked to word will not add sums in word Robin Excel Discussion (Misc queries) 0 March 31st 09 11:10 PM
Excel 7, paste linked to word becomes black when word pdf'd Surffreak Excel Discussion (Misc queries) 0 June 1st 08 12:17 AM
Copy from Word to Excel, and retain indent, plus word wrap Eric Excel Discussion (Misc queries) 1 March 9th 07 03:15 AM
Print labels by using Excel data in a Word mail into word Zoey Excel Discussion (Misc queries) 1 November 1st 05 09:08 PM


All times are GMT +1. The time now is 04:00 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"