Recording Macros

D

Denise Payne

Hello-
Can anyone explain how to record a macro. I went to Help and followed the
instructions, but it does not work. I am using a Command Button to try and
open a spreadsheet then put it in a module.
Thanks!
 
D

Doug Robbins - Word MVP

Is this in Word or Excel? If the latter, it would be better to post to
microsoft.public.excel.programming.

Aside from that, you should explain exactly what you want to achieve. What
exactly do you mean by "putting a spreadsheet into a module"?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
D

Denise Payne

I am using Excel.
What I am trying to do is use a Command Button to link to a macro that will
open a speadsheet from another file(Spreadsheet 1), then update another
spreadsheet(Spreadsheet 2) from the first spreadsheet. Then, close
everything. It is modeling data and there are 4323 rows and 50 columns. I am
trying to create a command on one spreadsheet that will update the data at
the touch of a button.
--
Denise Payne


Doug Robbins - Word MVP said:
Is this in Word or Excel? If the latter, it would be better to post to
microsoft.public.excel.programming.

Aside from that, you should explain exactly what you want to achieve. What
exactly do you mean by "putting a spreadsheet into a module"?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
G

Graham Mayor

This forum is for Word vba - Excel has its own programming forums.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
M

macropod

Hi Denise,

You should really have posted this in an NG like microsoft.public.excel.programming, but here's some code you could use. It includes
a variety of error checks before trying to open the file:
Option Explicit
Dim wbFullName As String

Function IsLocked(wbFullName As String) As Boolean
On Error Resume Next
Open wbFullName For Binary Access Read Write Lock Read Write As #1
Close #1
IsFileOpen = Err.Number
Err.Clear
End Function

Sub OpenWorkbook()
Dim wbName As String
Dim wbPath As String
wbPath = "c:\data\"
wbName = "test.xls"
wbFullName = wbPath & wbName
If Dir(wbFullName) = "" Then
MsgBox "Cannot find: " & wbFullName
ElseIf Not Workbooks(wbName) Is Nothing Then
MsgBox "The file: " & wbFullName & " is already open!"
ElseIf IsLocked(wbFullName) Then
MsgBox "The file: " & wbFullName & " is in use by another user!"
Else
Workbooks.Open wbFullName
End If
End Sub

Simply change the path & filename to suit your needs.

--
Cheers
macropod
[MVP - Microsoft Word]


Denise Payne said:
I am using Excel.
What I am trying to do is use a Command Button to link to a macro that will
open a speadsheet from another file(Spreadsheet 1), then update another
spreadsheet(Spreadsheet 2) from the first spreadsheet. Then, close
everything. It is modeling data and there are 4323 rows and 50 columns. I am
trying to create a command on one spreadsheet that will update the data at
the touch of a button.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top