LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Can't manually open file after coding.

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("Sav e as Web
Page...").Delete

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

' MenuBars(xlWorksheet).Menus("File").MenuItems("Sen d 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




 
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
How to confirm the open dialogue box by using macro coding? Eric Excel Worksheet Functions 3 June 13th 07 12:54 PM
VBE file open coding Bill Excel Programming 2 January 28th 05 08:25 PM
Manually assigning Macros to Buttons w/o File Dependence TMAC Excel Programming 1 September 17th 04 05:03 PM
Manually assigning Macros to Buttons w/o File Dependence John Loo Excel Programming 0 September 17th 04 04:33 PM
Hard-Coding a File Location ibeetb Excel Programming 1 April 15th 04 06:46 PM


All times are GMT +1. The time now is 08:57 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"