|
|
Thanks foe reply
But there is no +ve output.I need visible=False or hide powerpoint application.
There is no any option to hide or flas powerpoint application.
Please he me
|
|
|
|
|
what do you think of this
Const SW_HIDE = 0
Const SW_SHOWNORMAL = 1
Const SW_SHOWMINIMIZED = 2
Const SW_SHOWMAXIMIZED = 3
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const ERR_NO_WINDOW_HANDLE As Long = 1000
Const ERR_WINDOW_LOCK_FAIL As Long = 1001
Const ERR_VERSION_NOT_SUPPORTED As Long = 1002
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As Long) As Long
Declare Function LockWindowUpdate Lib "user32" (ByVal hwndLock As Long) As Long
Declare Function UpdateWindow Lib "user32" (ByVal hwnd As Long) As Long
Sub sOpenPowerpoint()
Dim pPT As PowerPoint.Application
Dim pPTopen As PowerPoint.Presentation
Dim PptName As String
PptName = "C:\A\Nice.pptx"
Set pPT = CreateObject("PowerPoint.Application")
pPT.Visible = True
Set pPTopen = pPT.Presentations.Open(PptName)
nHandle = fHandle
ShowWindow nHandle, SW_HIDE
End Sub
Function fHandle() As Long
Static hwnd As Long
Dim VersionNo As String
' Get Version Number
VersionNo = Left(Application.Version, InStr(1, Application.Version, ".") - 1)
' Get handle to the main application window using ClassName
Select Case VersionNo
Case "8" ' For PPT97:
hwnd = FindWindow("PP97FrameClass", 0&)
Case "9" ' For PPT2K:
hwnd = FindWindow("PP9FrameClass", 0&)
Case "10" ' For XP:
hwnd = FindWindow("PP10FrameClass", 0&)
Case "11" ' For 2003:
hwnd = FindWindow("PP11FrameClass", 0&)
Case "12" ' For 2007:
hwnd = FindWindow("PP12FrameClass", 0&)
Case Else
Err.Raise Number:=vbObjectError + ERR_VERSION_NOT_SUPPORTED, _
Description:="Supported for PowerPoint 97/2000/2002/2003 only."
Exit Function
End Select
If hwnd = 0 Then
Err.Raise Number:=vbObjectError + ERR_NO_WINDOW_HANDLE, _
Description:="Unable to get the PowerPoint Window handle"
Exit Function
End If
If LockWindowUpdate(hwnd) = 0 Then
Err.Raise Number:=vbObjectError + ERR_WINDOW_LOCK_FAIL, _
Description:="Unable to set a PowerPoint window lock"
Exit Function
End If
fHandle = hwnd
End Function
|
|
|
|
|
I guess you missed the copyright on that code snippet...
' --------------------------------------------------------------------------------
' Copyright ©1999-2009, Shyam Pillai, All Rights Reserved.
' --------------------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' --------------------------------------------------------------------------------
I don't mind you copy / pasting it really, but it fucking pisses me off that you don't at least give credit to the original link. (Here, by the way.[^])
and you could have posted the second entry on that page as well...
How to open a PowerPoint Show (*.pps) file thru code
It's fairly simple to open a PowerPoint file (*.ppt) for editing using VBA code however opening a PowerPoint Show (*.pps) file for editing is altogether another matter. Use the Presentation.Open method and it defaults to open the file in Slide Show mode. This might not be desirable. The routine below illustrates a manner of woring around the default behaviour and opening the file for editing. The routine also illustrates the use of the ScreenUpdating property (code listed above).
' --------------------------------------------------------------------------------
' Copyright ©1999-2009, Shyam Pillai, All Rights Reserved.
' --------------------------------------------------------------------------------
' You are free to use this code within your own applications, add-ins,
' documents etc but you are expressly forbidden from selling or
' otherwise distributing this source code without prior consent.
' This includes both posting free demo projects made from this
' code as well as reproducing the code in text or html format.
' --------------------------------------------------------------------------------
Sub OpenPPSForEdit()
On Error GoTo ErrHandle
Dim pShow As Presentation
' Lock the window to prevent refreshing
' See above article example for the code
ScreenUpdating = False
'Open the show, however use additional flag - WithWindow set to FALSE
Set pShow = Presentations.Open("C:\sample.pps", _
WithWindow:=msoFalse)
'Open a window now to the presentation for editing
pShow.NewWindow
' Unlock the window to start refreshing again
ScreenUpdating = True
Exit Sub
ErrHandle:
If Err.Number <> 0 Then
MsgBox Err.Number & " " & Err.Description, _
vbCritical + vbOKOnly, "Error"
End If
End Sub
|
|
|
|
|
I'm very sorry but I haven't read the remarques completly. It was my wrong thinking that it was already in the remarques. I read more carfully in the future.
However al that other code came also from internet.
|
|
|
|
|
It's Nice example.
But it's show error nHandle not define
modified on Friday, June 18, 2010 8:55 AM
|
|
|
|
|
|
I got again error
429 ActiveX component cann't create object
Please help me
modified on Friday, June 18, 2010 8:56 AM
|
|
|
|
|
in the declaration of handle its crearly tells function as long. So (almost) use the same datatype as the function
|
|
|
|
|
I am new to mdb data bases and trying to copy data from a column in one table to a column in another table.
Recently I wrote a short program to correct the data in one table of several mdb files. Below is the code I was using which works fine.
'removes unwanted characters from Optional Info23
Dim OpInfo23_upd As New OleDbCommand
OpInfo23_upd.CommandText = _
"UPDATE OP_INFO SET OPINFO23 = mid(OPINFO23,'2','8') & mid(OPINFO23,'11','2') WHERE OPINFO23 > ''"
OpInfo23_upd.Connection = conn
OpInfo23_upd.ExecuteNonQuery()
'sets flag character in Optional Info25
Dim OpInfo25_upd As New OleDbCommand
OpInfo25_upd.CommandText = _
"UPDATE OP_INFO SET OPINFO25 = mid(OPINFO23,'1','1')"
OpInfo25_upd.Connection = conn
OpInfo25_upd.ExecuteNonQuery()
Now I am attempting to add the code to copy the data from the NAME column in the required information table (REQ_INFO) to the OPINFO29 column in the optional information table (OP_INFO). I tried the code below, but it generates an exception. Is it possible to update the table directly from another table?
Dim OpInfo29_upd As New OleDbCommand
OpInfo29_upd.CommandText = _
"UPDATE OP_INFO SET OPINFO29 = REQ_INFO.NAME WHERE OP_INDEX = REQ_INFO.REQ_INDEX"
OpInfo29_upd.Connection = conn
OpInfo29_upd.ExecuteNonQuery()
|
|
|
|
|
And what is the exception message that is thrown?
|
|
|
|
|
No value given for one or more required parameters.
|
|
|
|
|
I think you need to do an inner join on the tables. Like:
UPDATE OP_INFO
INNER JOIN REQ_INFO ON OP_INFO.OP_INDEX = REQ_INFO.REQ_INDEX
SET OP_INFO.OPINFO29 = [REQ_INFO].[NAME];
It’s not because things are difficult that we do not dare, it’s because we do not dare that things are difficult. ~Seneca
modified on Thursday, June 17, 2010 5:20 PM
|
|
|
|
|
That worked perfectly. Thank you
|
|
|
|
|
Great. I had the table name wrong on the left-hand side of the SET but fixed it!
It’s not because things are difficult that we do not dare, it’s because we do not dare that things are difficult. ~Seneca
|
|
|
|
|
Hi All,
I am trying to add a dropdown to a column in a datagridview. Below is the code I use to populate the Datagridview.
Can I just add something to this to make 2nd and 3rd column have a dropdown or do I need to take a completely different aproach to achieve this.
The data for the dropdown will be the same for each row and will be extracted from an existing table.
Any help would be greatly appreciated.
I am using VS2005.
Private Sub FillBinDataGrid()
Dim SqlBin As String = _
"SELECT zz_ST_Binsheets.iStockLink, zz_ST_Binsheets.iBinSheetLine, " _
& "StkItem.Code, StkItem.Description_1, " _
& "zz_ST_Binsheets.iPacksize, zz_ST_Binsheets.fQuantity " _
& "FROM zz_ST_Binsheets LEFT JOIN " _
& "StkItem ON zz_ST_Binsheets.iStockLink = StkItem.StockLink " _
& "WHERE zz_ST_Binsheets.iBinSheetNr = @binnr "
Dim Sqlparam As SqlClient.SqlParameter
Sqlparam = New SqlClient.SqlParameter("@binnr", SqlDbType.Int)
Sqlparam.Value = BsBinNrTextbox.Text
Dim Conn As New SqlConnection(CntString)
Conn.Open()
Dim MyCommand As New SqlCommand(SqlBin, Conn)
MyCommand.Parameters.Add(Sqlparam)
Dim adapter As New SqlDataAdapter(MyCommand)
Dim dtset As New DataSet
adapter.Fill(dtset)
adapter.Dispose()
Conn.Close()
Dim table As DataTable = dtset.Tables(0)
With Me.BsDataGridView
.DataSource = table
.AutoResizeColumns()
.Columns(0).Visible = False
End With
End Sub
|
|
|
|
|
You will need to add a DataGridViewComboBoxColumn to your DataGridView. You will also need to set its DataSource, DisplayMember and ValueMember.
|
|
|
|
|
Thanks for the response, I will play around with that and see if I can get it to work.
|
|
|
|
|
Hi all,
for quite a long time I try to solve some event issue, try tons of sample code but can't come to a working result. Can someone please help me get forward a bit?
In my application, which is organized as plugin framework, I'm meanwhile able to raise events inside a "pluginClass" (which is part of every plugin) and receive them in a main pluginhandler class. But what I need to do is reacting to an event (button click) from the plugin's main form (i.e. another class). My current approach is not working:
1. Add a handler to the pluginClass, which has a SendList method raising an own event
AddHandler frmMain.ListSend, AddressOf SendList
Public Sub SendList(ByVal sender As Object, ByVal e As IPluginEventArgs)
RaiseEvent ListFilled(Me, New IPluginEventArgs() With {.plugin = Me, .currentEventName = "ListFilled"})
End Sub 3. Raise the forms ListSend event in the forms' respective event handler (button.click)
RaiseEvent ListSend(Me, New IPluginEventArgs)
The forms ListSend event is raised, but obviously the pluginClass doesn't listen and/or call the 'SendList' method. Where am I going wrong? Any advice appreciated... I'm more and more confused... and a bit desperate already.
Thank you
Michael
|
|
|
|
|
when you declare frmMain in the class that you want to catch the event, did you declare it while using the keyword WithEvents ?
|
|
|
|
|
Thank you for your time, elliot.
No, I didn't. Unfortunately changing the declaration didn't make any difference. Here's how the pluginClass creates an instance of the form and puts it into a panel of the MDI form as a control:
Public Sub UpdateMDI(ByVal MDIForm As IPluginMDIForm) Implements IPlugin.UpdateMainWindow
If startedAsPlugIn = false then exit sub
m_mainform = New frmMain
With m_mainform
.TopLevel = False
.FormBorderStyle = FormBorderStyle.None
.Dock = DockStyle.Left
MDIForm.TargetControl.Controls.Add(m_mainform)
MDIForm.TargetControl.Visible = True
.Visible = True
AddHandler frmMain.ListSend, AddressOf SendList
End With
End Sub
Private WithEvents m_mainform As Form = frmMain
Public ReadOnly Property MainForm() As Form Implements IPlugin.MainForm
Get
Return m_mainform
End Get
End Property
modified on Thursday, June 17, 2010 11:18 AM
|
|
|
|
|
I'm confused......
Is;
a) frmMain generated by the pluginClass
or b) pluginClass being instanced by frmMain
[edit: change message type to question]
Dave
Don't forget to rate messages!Find Me On: Web| Facebook| Twitter| LinkedInWaving? dave.m.auld[at]googlewave.com
modified on Thursday, June 17, 2010 10:05 AM
|
|
|
|
|
Thank you for helping, Dave. And sorry if I didn't express clear enough.
The pluginClass generates an instance of the form. I posted the code into my above answer, would you be so kind as to have another look there (with respect to the thread lenght I didn't put it twice)?
Maybe my whole approach is a bit clumsy, but it works just the way I want it to. Every plugin is supposed to use a particular area in the MDI, arranged through panels and splitters. Once a plugin is called, it's forms are added the different panels as controls. With the help of the splitters the user is able to adapt the different forms (panels) to his current needs.
|
|
|
|
|
Michael,
I just setup a new forms project;
1) Created an MDI form that had a single Panel to act as the container for the plugin Form
In the mdi form load event i called a sub which created the plugin class instance;
Private Plugin As PlugInClass
Private Sub MDIParent1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
AddChildFormToPanel()
End Sub
Private Sub AddChildFormToPanel()
Plugin = New PlugInClass(Me.FormPluginContainer)
End Sub
2) Created a Plugin Class which instantiates the form and loads it into the panel of the mdiform, the class also has a sub which handles the forms event.
Public Class PlugInClass
Private WithEvents m_mainform As FormPlugin
Public Sub New(ByRef TargetPanel As Panel)
m_mainform = New FormPlugin
With m_mainform
.TopLevel = False
.FormBorderStyle = FormBorderStyle.None
.Dock = DockStyle.Left
TargetPanel.Controls.Add(m_mainform)
.Visible = True
End With
End Sub
Private Sub thePluginFormRaisedAnEvent() Handles m_mainform.ButtonPressed
MsgBox("The Plug In Form Raised An Event in the PlugInClass")
End Sub
End Class
3) Created a PlugIn Form with a single button, that raises an event when clicked.
Public Event ButtonPressed()
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
RaiseEvent ButtonPressed()
End Sub
Ran the project, the form was created and loaded into the mdiform panel.
When the button is clicked the Class happily raises the message box.
I think this is what you are trying to do, and it appears to work just fine, although i didn't use any AddHandler calls, and passed in ByRef the panel where the form should be placed in the constructor for the class.
All appears to work fine.
|
|
|
|
|
Wow... that's exactly what I'm trying to do. So at least I was on the right track somehow
I'll sit down immediately, compare the differences and adapt my code. Let you know the result then! Thanks again - and for the big effort I'd really love to rate this advice with a double maximum
|
|
|
|