LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #7   Report Post  
Posted to microsoft.public.excel.programming
Sam Sam is offline
external usenet poster
 
Posts: 699
Default populate word from excel: On clickin "Export" button in excel

Hey Ryan, I am not getting any errors with the code now, But the data is
still not exported to word document. Is there anything I am missing?

Thanks in advance

"ryguy7272" wrote:

Check your email. This issue has been resolved. Not sure what the problem
was; maybe the word doc got corrupted. It seemed like you have things set up
right. Anyway, it works fine now.

HTH,
Ryan---
--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"sam" wrote:

Thank you for all your help, I did work on it and I do understand how it is
done.. But I think I am missing something here, I will send you the files.
Thanks a lot again

"ryguy7272" wrote:

As I recall, you open run the code from Excel, search for the word doc, click
it to open, and the data gets pushed from Excel to Word. If you send me the
two files I'll do it for you. However, you won't learn as much that way.

Ryan--


--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"sam" wrote:

Tried again... I am getting an error "This command is not available because
no document is open" on this line:
objWord.ActiveDocument.variables("Address").Value = Range("Address").Value

Few questions: I have saved the Word file with "Address" field name and done
same in excel with the same name. Should I save the word file at a specific
location? Should I save it as a Word template? or just a normal word file?
Here is my entire code:

Private Sub Export_Click()

Dim objWord As New Word.Application
Dim doc As Word.Document
Dim bkmk As Word.Bookmark
sWdFileName = Application.GetOpenFilename(, , , , False)
Set doc = objWord.Documents.Open(sWdFileName)

Set objWord = CreateObject("Word.Application")

objWord.ActiveDocument.variables("Address").Value = Range("Address").Value

objWord.Visible = True

Set objDoc = Nothing
Set objWord = Nothing
End Sub


Thanks in Advance


"ryguy7272" wrote:

I already answered this question for you. Did you follow the steps? Did you
enter a named range into Excel, and name it 'Address'? Did you create a
DocVariable in Word, and name it 'Address'? Did you add the reference to
Word from Excel? If not, look here for instructions on how to do this:
http://www.cpearson.com/excel/References.htm

You must have missed a step somewhere. i know that's how it is done; I've
done it many times.

Try again...

Goodluck,
Ryan---

--
Ryan---
If this information was helpful, please indicate this by clicking ''Yes''.


"sam" wrote:

Hi All, I want to populate a word template with data frome excel. I have
designed an "Export" button in excel sheet, which on clicking should populate
certain fields in a word file. Here is my code so far, But its not working!!
Any help would be highly appretiated.

Private Sub Export_Click()

Dim objWord As New Word.Application
Dim doc As Word.Document
Dim bkmk As Word.Bookmark
sWdFileName = Application.GetOpenFilename(, , , , False)

Set doc = objWord.Documents.Open(sWdFileName)

strTemplateName = "TestTemplate.dot"

strPathTemplateName = "C:\My Documents" & strTemplateName
Set objWord = CreateObject("Word.Application")


With objWord

.ActiveDocument.variables("Address").Value = Range("Address").Value

End With
objWord.Visible = True

Set objDoc = Nothing
Set objWord = Nothing
End Sub


Thanks in Advance

 
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
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
I need my export to include the "file as" category in Excel ChapmanManagement Excel Discussion (Misc queries) 1 May 15th 08 10:51 PM
Export to excel via webpage: "Invalid Procedure Call or Argument" Bruno Excel Programming 0 March 19th 08 11:55 AM
How do export Excel file to .txt delimited by "^"? JuliaMK Excel Discussion (Misc queries) 3 January 9th 07 05:39 PM
Folder Graphic (in Word & Pub) instead of "Close" button in Excel Susan ARC Excel Discussion (Misc queries) 1 September 3rd 06 04:34 AM


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