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

The questions are probably simple:

1 - can I create a macro that - after pointing (clicking, double
clicking) to e.g. B5 carries the pointer to e.g. W23?
2 -I'd like macro "waiting" after ActiveSheet.Pictures.Insert( _
(something like "Browse"). My macro inserts always the same picture.

Thank you for the hint...
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Excel macros

1. Rt-click the sheet tab - view code to take you into the sheet module

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
Cancel As Boolean)

If Target.Address = "$B$5" Then Range("W23").Select
End Sub

2.
In a normal module

Sub PictureInsert()
Dim sFileFilter As String, sTitle As String, sAddr As String
Dim vFile

On Error Resume Next
sAddr = ActiveCell.Address(0, 0)
On Error GoTo 0

If Len(sAddr) = 0 Then
MsgBox "First select cell in which to insert picture"
Exit Sub
End If

sFileFilter = "Picture files, *.bmp;*.jpg;*.gif"
sTitle = "Browse to Picture file to insert in cell : " & sAddr

vFile = Application.GetOpenFilename(sFileFilter, sTitle)

If Not vFile = False Then
ActiveSheet.Pictures.Insert vFile
End If

End Sub

Regards,
Peter T
"salonowiec" wrote in message
...
The questions are probably simple:

1 - can I create a macro that - after pointing (clicking, double
clicking) to e.g. B5 carries the pointer to e.g. W23?
2 -I'd like macro "waiting" after ActiveSheet.Pictures.Insert( _
(something like "Browse"). My macro inserts always the same picture.

Thank you for the hint...



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel macros

On 14 Mar, 11:27, "Peter T" <peter_t@discussions wrote:
1. Rt-click the sheet tab - view code to take you into the sheet module

Private Sub Worksheet_BeforeDoubleClick(ByVal Target As Range, _
* * * * * * Cancel As Boolean)

* * If Target.Address = "$B$5" Then Range("W23").Select
End Sub

2.
In a normal module

Sub PictureInsert()
Dim sFileFilter As String, sTitle As String, sAddr As String
Dim vFile

* * On Error Resume Next
* * sAddr = ActiveCell.Address(0, 0)
* * On Error GoTo 0

* * If Len(sAddr) = 0 Then
* * * * MsgBox "First select cell in which to insert picture"
* * * * Exit Sub
* * End If

* * sFileFilter = "Picture files, *.bmp;*.jpg;*.gif"
* * sTitle = "Browse to Picture file to insert in cell : " & sAddr

* * vFile = Application.GetOpenFilename(sFileFilter, sTitle)

* * If Not vFile = False Then
* * * * ActiveSheet.Pictures.Insert vFile
* * End If

End Sub

Regards,
Peter T"salonowiec" wrote in message

...

In point 1 it works wonderful... In 2 - after

If Not vFile = False Then

I'm getting error Type mismatch
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Excel macros

"salonowiec" wrote in message
<snip
In 2 - after
If Not vFile = False Then
I'm getting error Type mismatch


change
vFile = Application.GetOpenFilename(sFileFilter, sTitle)


to

vFile = Application.GetOpenFilename(sFileFilter, , sTitle)

'' or with named arguments
' vFile = Application.GetOpenFilename( _
FileFilter:=sFileFilter, _
Title:=sTitle)

FWIW, originally my code had the named arguments which I striped out so the
code could fit in one line in the post, oh well....

Regards,
Peter T


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Excel macros

On 14 Mar, 12:40, "Peter T" <peter_t@discussions wrote:
"salonowiec" wrote in message

<snip

In 2 - after
If Not vFile = False Then
I'm getting error Type mismatch


change

vFile = Application.GetOpenFilename(sFileFilter, sTitle)


to

vFile = Application.GetOpenFilename(sFileFilter, , sTitle)

'' or with named arguments
' vFile = Application.GetOpenFilename( _
FileFilter:=sFileFilter, _
Title:=sTitle)

FWIW, originally my code had the named arguments which I striped out so the
code could fit in one line in the post, oh well....

Regards,
Peter T


It's O.K. now, thank you very much...
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
Excel 2007 macros - how to merge 5 macros together into one Sue Excel Discussion (Misc queries) 1 April 16th 08 08:36 PM
Training: More on how to use macros in Excel: Recording Macros ToriT Excel Worksheet Functions 2 February 10th 06 07:05 PM
convert lotus 123w macros to excel macros rpiescik[_2_] Excel Programming 1 September 19th 04 12:41 PM
convert lotus 123w macros to excel macros rpiescik Excel Programming 1 September 18th 04 01:35 PM
Making excel macros run Word macros Matthew McManus Excel Programming 1 February 18th 04 02:57 AM


All times are GMT +1. The time now is 05:04 AM.

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"