Jump to content

Welcome to Geeks to Go - Register now for FREE

Geeks To Go is a helpful hub, where thousands of volunteer geeks quickly serve friendly answers and support. Check out the forums and get free advice from the experts. Register now to gain access to all of our features, it's FREE and only takes one minute. Once registered and logged in, you will be able to create topics, post replies to existing threads, give reputation to your fellow members, get your own private messenger, post status updates, manage your profile and so much more.

Create Account How it Works
Photo

userform msgbox in excel


  • Please log in to reply

#1
lrmac93

lrmac93

    New Member

  • Member
  • Pip
  • 4 posts
hi there,
i'm almost computer illiterate but my boss has asked me to put a warning on an Excel file. i.e.
When the file is opened, a message is to pop up warning the user of the content of the spreadsheet, before clicking a command button to either cancel or continue.

i can do the basics in Excel but have no idea about Visual Basic and i struggle with sometimes with macros.

any assistance would be greatly appreciated.

thanks!
  • 0

Advertisements


#2
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
hello VBA IS COOL

in excel, open the excel file

press alt-f11 (this brings up vb editor)
on the left side, should be a section with all sheets, etc assosiated with the excel file(Project - VBA Project)

choose the one called ThisWorkbook(dbl click)

see where it says (General)?click it and select Workbook

this will bring up in code

example:

Private Sub Workbook_Open()

' This is where you would put the code

End Sub


Any ways, u needed to show a message
where it says(' This is where you would put the code) in the example put this in

Msgbox "The message says hello", vbExclamation, "The Title"

so the following would be in the code

code:

'**************************************************
Private Sub Workbook_Open()
Msgbox "The message says hello", vbExclamation, "The Title"
End Sub
'****************************************************

Now
save the excel file and close it
now open it u should see a message pop up that says
"The message says hello" with a tilte "The Title" and an exclamation Mrk

Hope This helps if not post ur prob!!!

:tazz:

Stu Design
  • 0

#3
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
im busy right now ill tell u later on havinng a cancel button that closes the excel file if pressed and having the ok button continue!!!!

thanks a lot

Stu Design
  • 0

#4
lrmac93

lrmac93

    New Member

  • Topic Starter
  • Member
  • Pip
  • 4 posts
stu design,

thanks very much. that was so simple i'm almost embarrassed.
looking forward to your "second lesson for the clueless!"
cheers

lrmac93
  • 0

#5
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
ok the second part here goes

Private Sub Workbook_Open()
Msgbox "The message says hello", vbExclamation, "The Title"
End Sub

thats what was b4 not lets say u want to have the message
"Press Yes To Continue, No to Exit Excel"

Private Sub Workbook_Open()
'Declare your varaibel to check the answer
Dim x As Integer
' ask the question 
'notice the difference Msgbox "" vs Msgbox ("")?
'this is important
x = MsgBox("Press Yes To Continue, No to Exit Excel", vbYesNo, "Your Options")

'if the answer is yes
If x = vbYes Then
'then continue
End
End If

'if it equals no 
If x = vbNo Then

'this lies to the program saying it was saved(im assuming u dont want to save)
ThisWorkbook.Saved = True
'and close the workbook
ThisWorkbook.Close
End If
End Sub

there thats it

hope taht helped if u need any more help id be pleased to help
:tazz: ;)

Stu Design
  • 0

#6
lrmac93

lrmac93

    New Member

  • Topic Starter
  • Member
  • Pip
  • 4 posts
thanks stu design, the boss will be very impressed. i start writing up my bonus recommendation.

bye for now!
lrmac93
  • 0

#7
lrmac93

lrmac93

    New Member

  • Topic Starter
  • Member
  • Pip
  • 4 posts
back again!

i have a small problem.

if the user selects "disable macros", when the macro warning comes up, they are allowed into the spreadsheet without receiving my caveat!

is there away to close the spreadsheet if the user selects " disable macros"?

lrmac93
  • 0

#8
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
ill check it out
  • 0

#9
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
ok i got a question

the worksheet uare opening or workbook?
is it on a network?

ohh and u should go in excel to

tools, macros, security

and set it to low, in most cases it should not bring up the message

Stu Design

Edited by stu_design, 19 May 2005 - 11:05 AM.

  • 0

#10
stu_design

stu_design

    Member

  • Member
  • PipPipPip
  • 217 posts
beware

if its on fixed network, all the computers should be manually set in excel with security as low(4 macros) this way, when they open it, they will not see the warning
  • 0






Similar Topics

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

As Featured On:

Microsoft Yahoo BBC MSN PC Magazine Washington Post HP