Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Errormessage when button is pressed twice or more

Hi

I created a new button in the Toolbar.
Then I connected the button to my macro.
When I press the button for the first time everything works just fine
Everything to this point happened in document.xls

When I press the button a second time I get a Message that Excel can't find macro file.csv!convert.

The macro does these things
1. it stores the name of the active workbook (which is "document.xls"
2. it saves the active workbook (which should also be "document.xls"
3. it saves a sheet of the workbook as "convert.csv
4. it reopens the file stored in (1) because "convert.csv" is the aktive dokumen
6. it closes ThisWorkbook (Funny but it is still "convert.csv"
5. it calls an extern EXE-File that works with "convert.csv" and finally deletes it (But it doesn't delete it now! It needs user Input!

P.S.: It only happens when the macro is called via a button. Using "run Macro" several times works fine


Here is the code
Sub Konvertieren(
Dim WBName As Strin
Const sPath = "E:\test\
WBName = ActiveWorkbook.FullNam
ActiveWorkbook.Sav
Application.DisplayAlerts = Fals
Sheets("transfer").SaveAs Filename:=sPath & "Convert.csv", FileFormat:=xlCS
Application.DisplayAlerts = Tru
Workbooks.Open WBNam
ThisWorkbook.Close savechanges = n
Shell (sVerzeichnis & "convert.exe"
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Errormessage when button is pressed twice or more

I assume the macro is in document.xls

When you change the name of the document.xls to convert.csv then the
reference in the button is changed to point to convert.csv.

You will need to add code that changes the onaction property of the button
to reference document.xls.

--
Regards,
Tom Ogilvy


"Pointerman" wrote in message
...
Hi!

I created a new button in the Toolbar.
Then I connected the button to my macro.
When I press the button for the first time everything works just fine.
Everything to this point happened in document.xls.

When I press the button a second time I get a Message that Excel can't

find macro file.csv!convert.

The macro does these things:
1. it stores the name of the active workbook (which is "document.xls")
2. it saves the active workbook (which should also be "document.xls")
3. it saves a sheet of the workbook as "convert.csv"
4. it reopens the file stored in (1) because "convert.csv" is the aktive

dokument
6. it closes ThisWorkbook (Funny but it is still "convert.csv")
5. it calls an extern EXE-File that works with "convert.csv" and finally

deletes it (But it doesn't delete it now! It needs user Input!)

P.S.: It only happens when the macro is called via a button. Using "run

Macro" several times works fine.



Here is the code:
Sub Konvertieren()
Dim WBName As String
Const sPath = "E:\test\"
WBName = ActiveWorkbook.FullName
ActiveWorkbook.Save
Application.DisplayAlerts = False
Sheets("transfer").SaveAs Filename:=sPath & "Convert.csv",

FileFormat:=xlCSV
Application.DisplayAlerts = True
Workbooks.Open WBName
ThisWorkbook.Close savechanges = no
Shell (sVerzeichnis & "convert.exe")
End Sub



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Errormessage when button is pressed twice or more

Hi Tom
thanks for your fast reply
I even started to solve that problem by code but stuck again (My main task was programming that exe-file in Delphi and I'm a total newbie in VBA).
I found an example where they change the OnAction event by code. They use FindControl with the button's ID but i have no idea where I should get the ID. I just created the Button and connected it to the macro. There was no way of giving it an ID

It would be very nice of you to get me another hint.
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Errormessage when button is pressed twice or more

Well, you should know where the button is since you created it - you
shouldn't need to "Find" it. Just refer to it directly. However, since you
want to refer to it in the macro triggered by clicking it, you can use the

set ctrl = CommandBars.ActionControl
' code to create convert.csv
' code to reopen documents.xls
ctrl.OnAction = "Documents.xls!MyMacro"

--
Regards,
Tom Ogilvy



"Ponterman" wrote in message
...
Hi Tom,
thanks for your fast reply!
I even started to solve that problem by code but stuck again (My main task

was programming that exe-file in Delphi and I'm a total newbie in VBA).
I found an example where they change the OnAction event by code. They use

FindControl with the button's ID but i have no idea where I should get the
ID. I just created the Button and connected it to the macro. There was no
way of giving it an ID.

It would be very nice of you to get me another hint.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Errormessage when button is pressed twice or more

Thank you very much! That's exactly what i've been searching for!


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
create a button when pressed it will +1 to another field mswisher Excel Discussion (Misc queries) 2 November 24th 09 04:34 PM
Enter button jumps to next cell each time its pressed!!!! evasmagacz Excel Discussion (Misc queries) 3 June 17th 07 08:37 PM
preventing button being pressed Mike Excel Discussion (Misc queries) 2 March 16th 06 03:47 PM
count how many times a button is pressed Mike Excel Discussion (Misc queries) 2 February 5th 06 09:38 PM
Trapping key pressed in a worksheet John[_35_] Excel Programming 1 February 28th 04 05:46 AM


All times are GMT +1. The time now is 10:14 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"