Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Printing text from a textbox in a userform using vba code

First of all I have many issues and I am thankful for this website for
discussion purposes and any others - thanks all and thank you google
groups. I am having trouble getting a userform to print what is in a
textbox or I could even settle for it printing from an specific set of
cells in a excel worksheet using the userform and a command button to
intiate the process? I hope I am clear probably I am not I apolligize.
I also could settle for being able to include hyperlinks into a
userform after searching and excel sheet and retrieving data from
specific cell on a worksheet.

This is my example of trying to get the userform to print the value of
textbox2

Private Sub CommandButton2_Click()
UserForm1.texbox2.Text.PrintOut Copies:=1, Collate:=True
End Sub

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,117
Default Printing text from a textbox in a userform using vba code

i don't think you can just print the value.
you have to transfer the value onto a worksheet
and then print that.

Zigball wrote:
This is my example of trying to get the userform to print the value of
textbox2

Private Sub CommandButton2_Click()
UserForm1.texbox2.Text.PrintOut Copies:=1, Collate:=True
End Sub


Private Sub CommandButton2_Click()
Range("A1").Value = textbox2.Value
ActiveWorksheet.PrintOut
End Sub

xxxxxxxxxxxxxxxxxxxx
susan

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Printing text from a textbox in a userform using vba code

for hyperlinks on a userform:

http://www.j-walk.com/ss/excel/tips/tip71.htm
as John Walkenbach's site.

If you want to print the userform including the textboxes:

Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

'Public Const VK_SNAPSHOT = &H2C

Public Const VK_SNAPSHOT = 44
Public Const VK_LMENU = 164
Public Const KEYEVENTF_KEYUP = 2
Public Const KEYEVENTF_EXTENDEDKEY = 1


Sub Test()
UserForm1.Show
End Sub


In the userform module:




Private Sub CommandButton1_Click()
' keybd_event VK_SNAPSHOT, 0, 0, 0
DoEvents
keybd_event VK_LMENU, 0, _
KEYEVENTF_EXTENDEDKEY, 0 ' key down
keybd_event VK_SNAPSHOT, 0, _
KEYEVENTF_EXTENDEDKEY, 0
keybd_event VK_SNAPSHOT, 0, _
KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
keybd_event VK_LMENU, 0, _
KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
DoEvents
Workbooks.Add
Application.Wait Now + TimeValue("00:00:01")
ActiveSheet.PasteSpecial Format:="Bitmap", _
Link:=False, DisplayAsIcon:=False
ActiveSheet.Range("A1").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWorkbook.Close False
End Sub

--
Regards,
Tom Ogilvy


"Zigball" wrote:

First of all I have many issues and I am thankful for this website for
discussion purposes and any others - thanks all and thank you google
groups. I am having trouble getting a userform to print what is in a
textbox or I could even settle for it printing from an specific set of
cells in a excel worksheet using the userform and a command button to
intiate the process? I hope I am clear probably I am not I apolligize.
I also could settle for being able to include hyperlinks into a
userform after searching and excel sheet and retrieving data from
specific cell on a worksheet.

This is my example of trying to get the userform to print the value of
textbox2

Private Sub CommandButton2_Click()
UserForm1.texbox2.Text.PrintOut Copies:=1, Collate:=True
End Sub


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Printing text from a textbox in a userform using vba code

Thank You Susan this was a great help!
Susan wrote:
i don't think you can just print the value.
you have to transfer the value onto a worksheet
and then print that.

Zigball wrote:
This is my example of trying to get the userform to print the value of
textbox2

Private Sub CommandButton2_Click()
UserForm1.texbox2.Text.PrintOut Copies:=1, Collate:=True
End Sub


Private Sub CommandButton2_Click()
Range("A1").Value = textbox2.Value
ActiveWorksheet.PrintOut
End Sub

xxxxxxxxxxxxxxxxxxxx
susan


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 59
Default Printing text from a textbox in a userform using vba code

Thank You Tom I will try this, Thanks!

Tom Ogilvy wrote:
for hyperlinks on a userform:

http://www.j-walk.com/ss/excel/tips/tip71.htm
as John Walkenbach's site.

If you want to print the userform including the textboxes:

Declare Sub keybd_event Lib "user32" (ByVal bVk As Byte, _
ByVal bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

'Public Const VK_SNAPSHOT = &H2C

Public Const VK_SNAPSHOT = 44
Public Const VK_LMENU = 164
Public Const KEYEVENTF_KEYUP = 2
Public Const KEYEVENTF_EXTENDEDKEY = 1


Sub Test()
UserForm1.Show
End Sub


In the userform module:




Private Sub CommandButton1_Click()
' keybd_event VK_SNAPSHOT, 0, 0, 0
DoEvents
keybd_event VK_LMENU, 0, _
KEYEVENTF_EXTENDEDKEY, 0 ' key down
keybd_event VK_SNAPSHOT, 0, _
KEYEVENTF_EXTENDEDKEY, 0
keybd_event VK_SNAPSHOT, 0, _
KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
keybd_event VK_LMENU, 0, _
KEYEVENTF_EXTENDEDKEY + KEYEVENTF_KEYUP, 0
DoEvents
Workbooks.Add
Application.Wait Now + TimeValue("00:00:01")
ActiveSheet.PasteSpecial Format:="Bitmap", _
Link:=False, DisplayAsIcon:=False
ActiveSheet.Range("A1").Select
ActiveWindow.SelectedSheets.PrintOut Copies:=1
ActiveWorkbook.Close False
End Sub

--
Regards,
Tom Ogilvy


"Zigball" wrote:

First of all I have many issues and I am thankful for this website for
discussion purposes and any others - thanks all and thank you google
groups. I am having trouble getting a userform to print what is in a
textbox or I could even settle for it printing from an specific set of
cells in a excel worksheet using the userform and a command button to
intiate the process? I hope I am clear probably I am not I apolligize.
I also could settle for being able to include hyperlinks into a
userform after searching and excel sheet and retrieving data from
specific cell on a worksheet.

This is my example of trying to get the userform to print the value of
textbox2

Private Sub CommandButton2_Click()
UserForm1.texbox2.Text.PrintOut Copies:=1, Collate:=True
End Sub



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
Random Text in a userform textbox Soniya[_4_] Excel Programming 2 February 9th 06 01:28 PM
Help with UserForm textbox code excelnut1954 Excel Programming 1 January 9th 06 10:22 PM
Help with UserForm textbox code excelnut1954 Excel Programming 3 January 9th 06 09:34 PM
Using The Text From A Textbox In A UserForm Donna[_7_] Excel Programming 2 February 24th 05 03:25 PM
Adding TextBox to UserForm via code krzychu58 Excel Programming 1 September 24th 04 03:24 PM


All times are GMT +1. The time now is 09:52 PM.

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"