Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with Macro

Hi All,

I need help in writing this macro in Excel.
I have a worksheet that asks user to input certain values.
For example
Name:
Address:
The values is kept in B1 and B2

I need to pass this value to a Word Document.
Note that the Word Document is already bookmarked. so It
should be going to the 'spot'

Any suggestion?

Thanks
Robby
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Help with Macro

Untested:


Global objWd as Object, mydoc as Object

Var1 = [B1]
Var2=[B2]

On Error Resume Next
Set ObjWd = GetObject(, "Word.Application")
If Not TypeName(ObjWd) = "Nothing" Then
' ' Word Running
Else
' Word Not Running
NotRunning:
Set ObjWd = CreateObject("Word.Application")
End If
Debug.Print TypeName(ObjWd)
ObjWd.Visible = True
ObjWd.Activate
On Error GoTo 0
Set myDoc = ObjWd.Documents.Open(Blah Blah Blah)

with mydoc
.Selection.GoTo what:=wdGoToBookmark, Name:="your 1st bookmark
name"
.Selection.typetext text:=Var1
'repeat above 2 lines for Var2
end with



--
Hope this gets you started.
Roger
Shaftesbury (UK)







"Robby Saputra" wrote in message
...
Hi All,

I need help in writing this macro in Excel.
I have a worksheet that asks user to input certain values.
For example
Name:
Address:
The values is kept in B1 and B2

I need to pass this value to a Word Document.
Note that the Word Document is already bookmarked. so It
should be going to the 'spot'

Any suggestion?

Thanks
Robby



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Help with Macro

You might want to replace wdgotobookmark with its actual value:

? wdGoToBookmark
-1

If you have a reference set to word, you don't need to do this, but if not,
you do.

--
Regards,
Tom Ogilvy

"Roger Whitehead" wrote in message
...
Untested:


Global objWd as Object, mydoc as Object

Var1 = [B1]
Var2=[B2]

On Error Resume Next
Set ObjWd = GetObject(, "Word.Application")
If Not TypeName(ObjWd) = "Nothing" Then
' ' Word Running
Else
' Word Not Running
NotRunning:
Set ObjWd = CreateObject("Word.Application")
End If
Debug.Print TypeName(ObjWd)
ObjWd.Visible = True
ObjWd.Activate
On Error GoTo 0
Set myDoc = ObjWd.Documents.Open(Blah Blah Blah)

with mydoc
.Selection.GoTo what:=wdGoToBookmark, Name:="your 1st bookmark
name"
.Selection.typetext text:=Var1
'repeat above 2 lines for Var2
end with



--
Hope this gets you started.
Roger
Shaftesbury (UK)







"Robby Saputra" wrote in message
...
Hi All,

I need help in writing this macro in Excel.
I have a worksheet that asks user to input certain values.
For example
Name:
Address:
The values is kept in B1 and B2

I need to pass this value to a Word Document.
Note that the Word Document is already bookmarked. so It
should be going to the 'spot'

Any suggestion?

Thanks
Robby





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 29
Default Help with Macro

Ah, nice one Tom (again)

Thanks
Roger

"Tom Ogilvy" wrote in message
...
You might want to replace wdgotobookmark with its actual value:

? wdGoToBookmark
-1

If you have a reference set to word, you don't need to do this, but if

not,
you do.

--
Regards,
Tom Ogilvy

"Roger Whitehead" wrote in message
...
Untested:


Global objWd as Object, mydoc as Object

Var1 = [B1]
Var2=[B2]

On Error Resume Next
Set ObjWd = GetObject(, "Word.Application")
If Not TypeName(ObjWd) = "Nothing" Then
' ' Word Running
Else
' Word Not Running
NotRunning:
Set ObjWd = CreateObject("Word.Application")
End If
Debug.Print TypeName(ObjWd)
ObjWd.Visible = True
ObjWd.Activate
On Error GoTo 0
Set myDoc = ObjWd.Documents.Open(Blah Blah Blah)

with mydoc
.Selection.GoTo what:=wdGoToBookmark, Name:="your 1st

bookmark
name"
.Selection.typetext text:=Var1
'repeat above 2 lines for Var2
end with



--
Hope this gets you started.
Roger
Shaftesbury (UK)







"Robby Saputra" wrote in message
...
Hi All,

I need help in writing this macro in Excel.
I have a worksheet that asks user to input certain values.
For example
Name:
Address:
The values is kept in B1 and B2

I need to pass this value to a Word Document.
Note that the Word Document is already bookmarked. so It
should be going to the 'spot'

Any suggestion?

Thanks
Robby







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
Macro recorded... tabs & file names changed, macro hangs Steve Excel Worksheet Functions 3 October 30th 09 11:41 AM
Macro Help Needed - Excel 2007 - Print Macro with Auto Sort Gavin Excel Worksheet Functions 0 May 17th 07 01:20 PM
Macro needed to Paste Values and prevent Macro operation thunderfoot Excel Discussion (Misc queries) 0 June 10th 05 03:38 PM
macro to delete entire rows when column A is blank ...a quick macro vikram Excel Programming 4 May 3rd 04 08:45 PM
Start Macro / Stop Macro / Restart Macro Pete[_13_] Excel Programming 2 November 21st 03 05:04 PM


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