PC Review


Reply
Thread Tools Rate Thread

Can't manually open file after coding.

 
 
Cloudy
Guest
Posts: n/a
 
      17th Jun 2008
Here is the thing. Basically i have some codes here that enable and disbale
controls. There are also codes that open files. The thing is everything is
running perfectly on codes, like when i'm on file1 the codes bring me to
file2 etc. The problem comes now that i can only open file2 through codes. It
can't be done from the manual way of click through folders. Please help and
advice me what to do. Thanks!

The codes:

Private Sub Workbook_open()
If ActiveWorkbook.Name = "Monthly Accounts Portfolio_123.xls" Then
DisableCutAndPaste
Else:
Call EnableCutAndPaste
End If
End Sub


Sub ExcelInstances()
Dim xlApp1 As Object
Set xlApp1 = CreateObject("Excel.Application")
xlApp1.Visible = True
xlApp1.Workbooks.Open filename:="U:\Assets\Unsecured Loans\Cards\MIS\Disable
control wip\test\Monthly Accounts Portfolio_123.xls"
End Sub



Sub DisableCutAndPaste()
EnableControl 21, False ' cut
EnableControl 19, False ' copy
EnableControl 22, False ' paste
EnableControl 755, False ' pastespecial
EnableControl 3, False ' save
EnableControl 748, False ' saveas...
EnableControl 247, False ' pagesetup...
EnableControl 3823, False ' save as webpage
EnableControl 3655, False ' webpage preview
EnableControl 848, False ' move or copy sheet
EnableControl 846, False ' save workspace
EnableControl 30255, False ' print area
EnableControl 30095, False ' send to
EnableControl 762, False ' header & footer
EnableControl 30017, False 'macro
EnableControl 3738, False 'mail recipient



Application.OnKey "^s", ""

Application.OnKey "^c", ""

Application.OnKey "^x", ""

Application.OnKey "^p", ""

Application.OnKey "^w", ""

Application.OnKey "^v", ""

Application.OnKey "^+{F11}", ""

Application.OnKey "+{DEL}", ""

Application.OnKey "+{INSERT}", ""

Application.CellDragAndDrop = False



Dim Ctrl As Office.CommandBarControl
For Each Ctrl In Application.CommandBars.FindControls(Id:=847)
Ctrl.Enabled = False
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(Id:=889)
Ctrl.Enabled = False
Next Ctrl
For Each Ctrl In Application.CommandBars.FindControls(Id:=748)
Ctrl.Enabled = False
Next Ctrl





' MenuBars(xlWorksheet).Menus("File").MenuItems("Save as Web
Page...").Delete

' MenuBars(xlWorksheet).Menus("File").MenuItems("Save Workspace...").Delete

' MenuBars(xlWorksheet).Menus("File").MenuItems("Send To").Delete

' MenuBars(xlWorksheet).Menus("File").MenuItems("Web Page Preview").Delete



End Sub



Sub EnableControl(Id As Integer, Enabled As Boolean)

Dim CB As CommandBar

Dim C As CommandBarControl

Dim mb As MenuItems



For Each CB In Application.CommandBars

Set C = CB.FindControl(Id:=Id, recursive:=True)

If Not C Is Nothing Then C.Enabled = Enabled ' For Each mb In Application

' mb.Reset

' Next mb

Next



End Sub



Sub EnableCutAndPaste()

EnableControl 21, True ' cut

EnableControl 19, True ' copy

EnableControl 22, True ' paste

EnableControl 755, True ' pastespecial

EnableControl 2521, True ' print

EnableControl 109, True ' print preview

EnableControl 4, True ' print...

EnableControl 3, True ' saveas

EnableControl 748, True ' saveas...

EnableControl 247, True ' pagesetup...

EnableControl 3823, True ' save as webpage

EnableControl 3655, True ' webpage preview

EnableControl 848, True ' move or copy sheet

EnableControl 30095, True ' send to

EnableControl 846, True ' save workspace

EnableControl 30255, True ' print area

EnableControl 762, True ' header & footer

EnableControl 846, True ' save workspace

EnableControl 30017, True 'macro

EnableControl 3738, True 'mail recipient





Application.OnKey "^s"

Application.OnKey "^c"

Application.OnKey "^v"

Application.OnKey "^w"

Application.OnKey "^p"

Application.OnKey "^+{F11}"

Application.OnKey "+{DEL}"

Application.OnKey "+{INSERT}"



Application.CellDragAndDrop = True



Dim Ctrl As Office.CommandBarControl

For Each Ctrl In Application.CommandBars.FindControls(Id:=847)

Ctrl.Enabled = True

Next Ctrl

For Each Ctrl In Application.CommandBars.FindControls(Id:=889)

Ctrl.Enabled = True

Next Ctrl



For Each Ctrl In Application.CommandBars.FindControls(Id:=748)

Ctrl.Enabled = True

Next Ctrl



End Sub




 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Exploring the open sessions, manually connecting one Pavils Jurjans Microsoft ASP .NET 0 9th May 2006 12:46 PM
VBE file open coding =?Utf-8?B?QmlsbA==?= Microsoft Excel Programming 2 28th Jan 2005 08:25 PM
cant burn cd's and dvd rom drive wont open manually =?Utf-8?B?S3lsZQ==?= Windows XP Hardware 2 5th Oct 2004 03:19 AM
Can I manually close an open port? TW Microsoft Windows 2000 Security 1 3rd Aug 2004 04:29 AM
Can't manually open port Ly Windows XP Security 0 30th Jul 2003 08:53 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:57 AM.