Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Running macro automatic after opening Userform

Dear all,

I have the following problem: I'd created a userform with a Image
field. Now I'd like to asign a picture to that image field at the
moment you open the userform. I just can't get the macro to run
automatic after opening of the userform.

The code:

-----------------------------------------------------------------------
---------------------

Public Sub ShowPicture()

Dim CurrentChart1, Fname1

Set CurrentChart1 = Sheets("Picture").ChartObjects(1).Chart
Fname1 = ThisWorkbook.Path & "\temp1.gif"
CurrentChart1.Export Filename:=Fname1, FilterName:="GIF"

UserForm1.Show

Application.run "CommandButton1_Click"

End Sub

-----------------------------------------------------------------------
----------------------

Private Sub CommandButton1_Click()

Path1 = "c:"
Fname1 = Path1 & "\temp1.gif"
Image1.Picture = LoadPicture(Fname1)

End Sub
-----------------------------------------------------------------------
------------------------.

When I build Commandbutton1 on the Userform and click it, the picture
will show in the image field. I just like it to do it automatically
when i open the Userform. Anyone a solution?

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,101
Default Running macro automatic after opening Userform

Try

Call CommandButton1_Click

instead of

Application.run "CommandButton1_Click"

"Xentis" wrote:

Dear all,

I have the following problem: I'd created a userform with a Image
field. Now I'd like to asign a picture to that image field at the
moment you open the userform. I just can't get the macro to run
automatic after opening of the userform.

The code:

-----------------------------------------------------------------------
---------------------

Public Sub ShowPicture()

Dim CurrentChart1, Fname1

Set CurrentChart1 = Sheets("Picture").ChartObjects(1).Chart
Fname1 = ThisWorkbook.Path & "\temp1.gif"
CurrentChart1.Export Filename:=Fname1, FilterName:="GIF"

UserForm1.Show

Application.run "CommandButton1_Click"

End Sub

-----------------------------------------------------------------------
----------------------

Private Sub CommandButton1_Click()

Path1 = "c:"
Fname1 = Path1 & "\temp1.gif"
Image1.Picture = LoadPicture(Fname1)

End Sub
-----------------------------------------------------------------------
------------------------.

When I build Commandbutton1 on the Userform and click it, the picture
will show in the image field. I just like it to do it automatically
when i open the Userform. Anyone a solution?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Running macro automatic after opening Userform

Mike,

Thanks for your answer. It is better to use the call option.

In this case however I get a "Object variable or with block variable
not set"

I can't seem to get the first macro to recognize the image field in
the form. I 've now tried the code below
But it also gives a "Object required" error.

-----------------------------------------------------------------------
---------------
Public Sub ShowPicture()

Dim CurrentChart1, Fname1

Set CurrentChart1 = Sheets("Picture").ChartObjects(1).Chart
Fname1 = ThisWorkbook.Path & "\temp1.gif"
CurrentChart1.Export Filename:=Fname1, FilterName:="GIF"

UserForm1.Show vb Modeless

Path1 = "c:"
Fname1 = Path1 & "\temp1.gif"
Image1.Picture = LoadPicture(Fname1)

End Sub

-----------------------------------------------------------------------
--------------------

I'm not very experienced with this kind of problems so if anybody
could help I would be really glad.

Regards,

Xentis

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,123
Default Running macro automatic after opening Userform

Hi Xentis

moment you open the userform. I just can't get the macro to run
automatic after opening of the userform.


Call your macro in this event in the Userform module

Private Sub UserForm_Initialize()
Call yourmacroname
End Sub

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm


"Xentis" wrote in message ups.com...
Dear all,

I have the following problem: I'd created a userform with a Image
field. Now I'd like to asign a picture to that image field at the
moment you open the userform. I just can't get the macro to run
automatic after opening of the userform.

The code:

-----------------------------------------------------------------------
---------------------

Public Sub ShowPicture()

Dim CurrentChart1, Fname1

Set CurrentChart1 = Sheets("Picture").ChartObjects(1).Chart
Fname1 = ThisWorkbook.Path & "\temp1.gif"
CurrentChart1.Export Filename:=Fname1, FilterName:="GIF"

UserForm1.Show

Application.run "CommandButton1_Click"

End Sub

-----------------------------------------------------------------------
----------------------

Private Sub CommandButton1_Click()

Path1 = "c:"
Fname1 = Path1 & "\temp1.gif"
Image1.Picture = LoadPicture(Fname1)

End Sub
-----------------------------------------------------------------------
------------------------.

When I build Commandbutton1 on the Userform and click it, the picture
will show in the image field. I just like it to do it automatically
when i open the Userform. Anyone a solution?

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5
Default Running macro automatic after opening Userform

He Rob,

Dat doet het inderdaad. Super, Excel is best leuk als het werkt :-P.

gr,

Xentis

On 29 jan, 16:03, "Ron de Bruin" wrote:
Hi Xentis

moment you open the userform. I just can't get the macro to run
automatic after opening of the userform.Call your macro in this event in the Userform module


Private Sub UserForm_Initialize()
Call yourmacroname
End Sub

--

Regards Ron de Bruinhttp://www.rondebruin.nl/tips.htm



"Xentis" wrote in oglegroups.com...
Dear all,


I have the following problem: I'd created a userform with a Image
field. Now I'd like to asign a picture to that image field at the
moment you open the userform. I just can't get the macro to run
automatic after opening of the userform.


The code:


-----------------------------------------------------------------------
---------------------


Public Sub ShowPicture()


Dim CurrentChart1, Fname1


Set CurrentChart1 = Sheets("Picture").ChartObjects(1).Chart
Fname1 = ThisWorkbook.Path & "\temp1.gif"
CurrentChart1.Export Filename:=Fname1, FilterName:="GIF"


UserForm1.Show


Application.run "CommandButton1_Click"


End Sub


-----------------------------------------------------------------------
----------------------


Private Sub CommandButton1_Click()


Path1 = "c:"
Fname1 = Path1 & "\temp1.gif"
Image1.Picture = LoadPicture(Fname1)


End Sub
-----------------------------------------------------------------------
------------------------.


When I build Commandbutton1 on the Userform and click it, the picture
will show in the image field. I just like it to do it automatically
when i open the Userform. Anyone a solution?- Tekst uit oorspronkelijk bericht niet weergeven -- Tekst uit oorspronkelijk bericht weergeven -


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
Running macro upon opening workbook don Excel Programming 4 June 4th 06 06:17 PM
Automatic running of Macros praveen_khm[_28_] Excel Programming 2 February 20th 06 10:45 AM
Automatic running of Macro for the whole spreadsheet Rob Excel Programming 1 June 29th 05 08:19 PM
running macro at automatic time intervals tjb Excel Worksheet Functions 1 February 28th 05 09:40 PM
Closing the Userform when macro is running SuperJas Excel Programming 5 December 10th 03 05:31 AM


All times are GMT +1. The time now is 10:00 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"