Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default vba code to send a filename to word without starting a new session

Hello,

I got pretty far with my vba project but got stuck now.

What I have so far:
I have 2 monitors, on the left an excel sheet with filenames and on the right Word running.
When I click on a cell with a filename a Word session is started with the file opened.

The issue:
Each cell click results in a new Word session being started.

What Im looking for:
Vba code to tell a running Word session to display the file selected in question (and not open a new Word session)
The point being is that Word can be sized to best fit the right monitor and stay that way while different files are selected from excel and viewed in Word.

Probably some sort of DDE call needed but cant figure out how. In the near future Id like this to work for powerpoint, IE and pdf-readers as well.
Windows 7 and office 2010.

Maybe there is a generic document viewer which has the option €śallow only one instance€ť which would solve the issue as well.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default vba code to send a filename to word without starting a new session

Hello,

I got pretty far with my vba project but got stuck now.

What I have so far:
I have 2 monitors, on the left an excel sheet with filenames and on
the right Word running. When I click on a cell with a filename a Word
session is started with the file opened.

The issue:
Each cell click results in a new Word session being started.

What Im looking for:
Vba code to tell a running Word session to display the file selected
in question (and not open a new Word session) The point being is that
Word can be sized to best fit the right monitor and stay that way
while different files are selected from excel and viewed in Word.

Probably some sort of DDE call needed but cant figure out how. In
the near future Id like this to work for powerpoint, IE and
pdf-readers as well. Windows 7 and office 2010.

Maybe there is a generic document viewer which has the option €śallow
only one instance€ť which would solve the issue as well.


Word was designed that way. It always will open another doc in a new
'instance'. If you only need 1 doc open at a time you could close each
doc before opening another. This would require you start an instance of
Word from Excel, then use that 1 instance for all files. Optionally,
you could start an instance and set it up as desired, then grab a fully
qualified ref to it.

Generally speaking, it's not considered 'best practice' to hijack a
running instance of any app that supports multiple instances. That more
or less means if your Excel (or any other) VBA project needs to use
another app then you should create your own instance of that app...

Dim appWD As Object
Set appWD = CreateObject("Word.Application")

...and don't forget to release its mem space when done with it!

Set appWD = Nothing


If you manually start Word specifically for your Excel project's use
you can establish a link to it...

Dim appWD As Object

'Grab running instance
Set appWD = GetObject("Word.Application")
'If not running, start your own instance
If appWD Is Nothing Then Set appWD = CreateObject("Word.Application")

With appWD
'do stuff...
End With 'appWD

Set appWD = Nothing

FWIW
I've been authoring userguides, tech/instruction manuals, product user
manuals, statistical reports, slideshows, and ebooks in Excel since
v2000. I don't use Word much because I haven't found anything it can do
that can't be done in Excel equally as well or better.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default vba code to send a filename to word without starting a new session

On Tuesday, August 30, 2016 at 4:55:03 AM UTC+2, GS wrote:
Generally speaking, it's not considered 'best practice' to hijack a
running instance of any app that supports multiple instances. That more


It should be optional like some generic viewers are, you want a quick view and not be wasting time closing additional instances.

If you manually start Word specifically for your Excel project's use
you can establish a link to it...

Dim appWD As Object

'Grab running instance
Set appWD = GetObject("Word.Application")


Tnx, this works but is very slow to start.

I've reverted to using 'shell' and a portable generic viewer who has that single instance option so the viewer can stay in a fixed position on the second monitor.

Set b = ActiveSheet.Buttons(Application.Caller)
With b.TopLeftCell
cs = .Column
rs = .Row
End With
Set Rng = ActiveSheet.Range(CStr(cs) + CStr(rs))
TaskID = Shell("C:\Program Files\gviewer\viewer.exe" + " " + Rng, vbHide)

Fast, no office starttime overhead or none-requested conversions, you click and its immediately on the screen.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,182
Default vba code to send a filename to word without starting a new session

On Tuesday, August 30, 2016 at 4:55:03 AM UTC+2, GS wrote:
Generally speaking, it's not considered 'best practice' to hijack a
running instance of any app that supports multiple instances. That
more


It should be optional like some generic viewers are, you want a quick
view and not be wasting time closing additional instances.

If you manually start Word specifically for your Excel project's use
you can establish a link to it...

Dim appWD As Object

'Grab running instance
Set appWD = GetObject("Word.Application")


Tnx, this works but is very slow to start.

I've reverted to using 'shell' and a portable generic viewer who has
that single instance option so the viewer can stay in a fixed
position on the second monitor.

Set b = ActiveSheet.Buttons(Application.Caller)
With b.TopLeftCell
cs = .Column
rs = .Row
End With
Set Rng = ActiveSheet.Range(CStr(cs) + CStr(rs))
TaskID = Shell("C:\Program Files\gviewer\viewer.exe" + " " + Rng,
vbHide)

Fast, no office starttime overhead or none-requested conversions, you
click and its immediately on the screen.


Nice! It still leaves your project with a dependency, making
distribution more complex than it needs be. IMO, a NewWindow in Excel
would suffice.

--
Garry

Free usenet access at http://www.eternal-september.org
Classic VB Users Regroup!
comp.lang.basic.visual.misc
microsoft.public.vb.general.discussion

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

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
Problem with .send from microsoft example for vba send mail from excel code Mark Stephens Excel Programming 3 March 6th 09 03:05 PM
CreateObject("Word.Application") fails though Word session starts [email protected] Excel Programming 16 May 6th 08 02:40 PM
Startup and template locations in Citrix TS session and local session John Nurick Setting up and Configuration of Excel 2 September 21st 06 10:42 PM
Using Excel to start a merge session in Word luthor Excel Programming 0 April 20th 06 09:26 AM
My send to in excel/word does not offer send as attachment Mstink Excel Discussion (Misc queries) 11 March 16th 06 02:49 PM


All times are GMT +1. The time now is 04:35 PM.

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"