Excel poser.

  Chas49 15:16 21 Nov 09
Locked

Help appreciated with this problem please.

I have a worksheet in Excel with data in the first column that I wish to access.

The column contains numbers which represent the data in the columns to the right of it. (although for this query that is really irrelevant)

What I would like to do is to highlight a particular number and, by means of VBA load a Word file containing a review of the data in that row, ie:- No. 67 when highlighted and a button clicked then a Word file with the filename 67 would be loaded from a folder containing such files.

The problem is ‘how, when I highlight the cell and click a button operating a macro do I program that macro to pick up the number in the highlighted cell’? Is it possible?

  VoG II 15:42 21 Nov 09

The code would be something like


Sub OpenWdFile()
Dim wdDoc As Object
Dim wdFileName As Variant
wdFileName = ActiveCell.Value
Set wdDoc = GetObject(wdFileName) 'open Word file
End Sub

  VoG II 16:04 21 Nov 09

Actually I think this is better


Sub OpenWdFile()
Dim objWord As Word.Application
Dim doc As Word.Document
Set objWord = New Word.Application
Set doc = objWord.Documents.Open(Filename:=ThisWorkbook.Path & "\" & ActiveCell.Value, Visible:=True)
End Sub

  Chas49 16:48 21 Nov 09

As usual VoG™ you're there when needed - it's some time since I used VBA and I'd forgotten the Activecell instruction. Many thanks for the quick reply - I shall have a go with this after tea.

This thread is now locked and can not be replied to.

Surface Pro 5 News - release date, UK price, features, specs

Gear VR vs. Daydream: Which delivers the best VR experience?

iPad Pro 12.9 vs Surface Pro 5