Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2005

Tip: Looking for answers? Try searching our database.

Scroll a Word doc programmatically

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Joan Xiao - 13 Sep 2005 22:40 GMT
I'd like to have a Word doc scrolled to a desired location when user opens
it. How can this be done programmatically?

Thanks  very much for your help.
Anne Troy - 13 Sep 2005 22:51 GMT
Try this, Joan: http://vbaexpress.com/kb/getarticle.php?kb_id=63
************
Anne Troy
www.OfficeArticles.com

> I'd like to have a Word doc scrolled to a desired location when user opens
> it. How can this be done programmatically?
>
> Thanks  very much for your help.
Joan Xiao - 13 Sep 2005 23:19 GMT
Thanks Anne for the reply. However, I tried the code and it doesn't work for
me.  I even downloaded the Word doc, but it  doesn't work. I have Windows XP
Professional and Word 2003.

The article says "Place selection point at whatever location you want to
mark." to test the code. I assume this means moving the mouse to the desired
location? Anyway, I tried using the mouse, with and without scrolling, or
mving down using the arrow key, and saved the document afterwards, but it
didn't go to the last location when I re-opened it.

I'd appreciate it if you could help me further.

Thanks.

Joan
Anne Troy - 13 Sep 2005 23:53 GMT
Are you allowing macros to run, Joan? Tools-->Macro-->Security, must be
medium (preferred) or low. If you aren't allowing the macro to run, nothing
will happen. :)
************
Anne Troy
www.OfficeArticles.com

> Thanks Anne for the reply. However, I tried the code and it doesn't work
> for
[quoted text clipped - 14 lines]
>
> Joan
Joan Xiao - 14 Sep 2005 01:36 GMT
Thanks again Anne.

You are right,  my macro security was set to high. After I change it to
medium, it works!

As you can tell, I'm a dummy in VB -- I'm a Java developer and don't know
anything about VB programming in Word, but I need to explore and see whether
VB can achieve what I need do.

I have a web application which launches a Word doc. Depending on user input,
I'd like to have the Word doc opened at  a desired location automatically. So
I guess I need create bookmarks for all key words and when a user opens the
doc, one of the bookmarks needs to be selected depending on the value of the
input. How can I pass the parameter to Word?

Do you think this can be done? If not, let's forget about the web
application,  how can this be done in Word itself?

I greately appreciate your help.

Joan
Greg Maxey - 14 Sep 2005 01:47 GMT
Joan,

I'm not Anne and I don't know how to do it with a web application, but from
within Word you could do it something like this:

Sub Document_Open()
Selection.GoTo What:=wdGoToBookmark, Name:="Test"
End Sub

Where "Test" is one of the named bookmarks.

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Thanks again Anne.
>
[quoted text clipped - 18 lines]
>
> Joan
Anne Troy - 14 Sep 2005 02:14 GMT
Thank GAWD you answered, Greg. I sure couldn't have.
************
Anne Troy
www.OfficeArticles.com

> Joan,
>
[quoted text clipped - 29 lines]
>>
>> Joan
Greg Maxey - 14 Sep 2005 02:34 GMT
Anne,

I just answered half the question.  Standing by for one of the Senseis to
come along and answer the complete question ;-)

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> Thank GAWD you answered, Greg. I sure couldn't have.
> ************
[quoted text clipped - 40 lines]
>>>
>>> Joan
Helmut Weber - 14 Sep 2005 08:58 GMT
Hi everybody,

this one works for me, and hardly anything else,
except one could use another object to scroll into view.

Public Sub autoopen()
Application.OnTime When:=Now + TimeValue("00:00:02"), _
   Name:="PlaceMe"
End Sub

Sub PlaceMe()
ActiveWindow.ScrollIntoView ActiveDocument.Bookmarks("Mark1").Range
End Sub

Some refinements or error handling possible.

Helmut Weber
Joan Xiao - 14 Sep 2005 20:27 GMT
Thanks everyone for your post. The information you provided has been
definitely very helpful.

So is it possible to pass a parameter to Word somehow? My feeling is that it
isn't possible, espeically because in a web application, Word is launched by
a browser and I just don't see how any parameter can be set.

An alternative for me is to dynamically create the macros. For example, read
a plain Word doc (with no macros), create a macro on the fly and then insert
it into the original doc. But then I need know how macros are stored in a
Word doc.  Has anyone done something like this? Where can I find any
information related to this?

Thanks a lot.

Joan
Jean-Guy Marcil - 15 Sep 2005 02:10 GMT
Joan Xiao was telling us:
Joan Xiao nous racontait que :

> Thanks everyone for your post. The information you provided has been
> definitely very helpful.
[quoted text clipped - 9 lines]
> know how macros are stored in a Word doc.  Has anyone done something
> like this? Where can I find any information related to this?

You can have a VB Script on a Web page that will create a Word document.
Also, I believe that VB Scripting can read info from the Web page.
So, it seems that you could read a field content, store it in a variable,
create/open the Word document, and, from within the VB Script run some code
passing it the variable you got prior to creating the Word object.

In pseudocode:

myVar = WebPageControlContent
WordDoc = Open Word Document
WordDoc.GoTo What:=wdGoToBookmark, Name:=myVar

Signature

Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org 

Joan Xiao - 15 Sep 2005 18:12 GMT
Thanks Jean for the reply. The problem is that my web application is Java
(J2EE) based, so I don't think it can execute any code in VBA.

Does anyone know how Word stores a macro in a doc? I'm really thinking af
programmatically creating the macros and insert them into Word docs.

Thanks.

Joan
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.