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

Hello,
So I have this word document that creates a report that is almost completely
automated except for one thing.
At the bottom of the document there are three graphs, each of the three
graphs is linked to one of three seperate Excel files. Each of the 3 excel
file has 12 sheets, one for each month.
What I want to see if I can do is create a dynamic link to the graph, in the
correct worksheet, for the correct month. Without having to manually delete
and relink each graph when the month changes.

i.e... So if the month is August I want the graph from the sheet named " Aug
'08 "

Here is an example of the field codes for one of the graphs in the doc.

{ LINK Excel.Sheet.8 "\\\\WCHWF70\\share\\Interactive\\Reporting\\Graph s
Charts 2008\\Sales.xls" "Aug '08![Sales.xls]Aug '08 Chart 1" \a \p }



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 516
Default Creating a Dynamic Link from Excel to Word

Nevermind I was able to work it out.

This is what I came up with:
'________________________________________________
Dim afield as field
Dim counter As Integer

Dim iDay As Integer
Dim iMonth As Integer
Dim dtYesterday As Date
dtYesterday = DateAdd("d", -1, Now)
iDay = DatePart("d", dtYesterday)
iMonth = DatePart("m", dtYesterday)

Dim xMonth As String
Dim lastMonth As String
xMonth = MonthName(iMonth, True)
lastMonth = MonthName(DatePart("m", Date - 20), True)


counter = ActiveDocument.Fields.Count

For i = 286 To counter
Set afield = ActiveDocument.Fields(i)
If InStr(1, afield.Code.Text, xMonth, vbTextCompare) 0 Then
afield.Code.Text = Replace(afield.Code, xMonth, lastMonth, , , _
vbTextCompare)
End If
Next
'This searches through the field.code.text which is what the field code
looks like on my previous post, searches through and replaces it with the
correct month using a dateadd and monthname functions.
'_________________________________________________


"matt" wrote:

Hello,
So I have this word document that creates a report that is almost completely
automated except for one thing.
At the bottom of the document there are three graphs, each of the three
graphs is linked to one of three seperate Excel files. Each of the 3 excel
file has 12 sheets, one for each month.
What I want to see if I can do is create a dynamic link to the graph, in the
correct worksheet, for the correct month. Without having to manually delete
and relink each graph when the month changes.

i.e... So if the month is August I want the graph from the sheet named " Aug
'08 "

Here is an example of the field codes for one of the graphs in the doc.

{ LINK Excel.Sheet.8 "\\\\WCHWF70\\share\\Interactive\\Reporting\\Graph s
Charts 2008\\Sales.xls" "Aug '08![Sales.xls]Aug '08 Chart 1" \a \p }



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
Some mouse function disabled on creating dynamic link Billywiztheelder Excel Discussion (Misc queries) 0 July 29th 08 01:00 PM
PASTE LINK option not available when I select PASTE SPECIAL to link an image in Excel to a Word document. tln Links and Linking in Excel 0 April 22nd 07 04:28 PM
Link table from excel to word using word VBA [email protected] Excel Discussion (Misc queries) 7 January 9th 07 05:57 PM
Link table from excel to word using word VBA [email protected] Excel Programming 7 January 9th 07 05:57 PM
Creating a TEXT formula to link a word in one cell with a number v Michelle Excel Programming 1 February 2nd 06 04:21 PM


All times are GMT +1. The time now is 10:17 AM.

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

About Us

"It's about Microsoft Excel"