Prezados, boa tarde!
Desenvolvo e utilizo um sistema de controle de despesas pessoais todo em VBA. Este funciona perfeitamente, porém, infelizmente, convivo com um incomodo tremendo, pois caso eu executá-lo ''por cima'' de outra planilha qualquer, o projeto referido apresenta o seguinte erro:
Utilizo este código no work book. Este fórum, teoricamente, ajudaria-me, mas não consegui, O que farei?:
viewtopic.php?f=10&t=8920
'Silently register a file with administrator elevated access
Sub RegisterFile(ByVal sFileName As String)
ShellExecute 0, "runas", "cmd", "/c regsvr32 /s " & """" & sFileName & """", "C:", 0 'SW_HIDE =0
End Sub
'Silently unregister a file with administrator elevated access
Sub UnRegisterFile(ByVal sFileName As String)
ShellExecute 0, "runas", "cmd", "/c regsvr32 /u /s " & """" & sFileName & """", "C:", 0 'SW_HIDE =0
End Sub
Sub Executar_Programação()
Application.Visible = False
UserForm7.Show
Application.Visible = True
End Sub
Private Sub Workbook_Activate()
Sheets("bd").Select
UserForm7.Show vbModeless 'vbModeless = Sem restrição de janela (Permite trabalhar com mais de um form ao mesmo tempo)
End Sub
Private Sub Workbook_AfterSave(ByVal Success As Boolean)
Sheets("tela de boas vindas").Select
End Sub
Private Sub Workbook_BeforeClose(Cancel As Boolean)
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Visible = True
Next ws
End Sub
Private Sub Workbook_Open()
Dim r As Range
Dim r1 As Range
Set r = Worksheets("bd").Range("A2").CurrentRegion
Set r1 = r.Offset(r.Rows.Count, 0)
ThisWorkbook.Worksheets("bd").Activate
Dim ws As Worksheet
For Each ws In ThisWorkbook.Worksheets
ws.Visible = True
Next ws
Application.Visible = False
Application.OnKey "{Escape}", ""
ActiveWindow.TabRatio = 0
Dim PCName As String
Dim P As Long
P = NameOfPC(PCName)
text1 = Trim(PCName)
[da1] = (text1)
UserForm7.Show
End Sub
Sub ip()
Dim wsh As Object
Dim RegEx As Object, RegM As Object
Dim FSO As Object, fil As Object
Dim ts As Object, txtAll As String, TempFil As String
Set wsh = CreateObject("WScript.Shell")
Set FSO = CreateObject("Scripting.FileSystemObject")
Set RegEx = CreateObject("vbscript.regexp")
TempFil = Environ$("TEMP")
If Right(TempFil, 1) <> "" Then TempFil = TempFil & ""
TempFil = TempFil & "myip.txt"
' Save ipconfig info to temporary file
wsh.Run "%comspec% /c ipconfig > " & TempFil, 0, True
With RegEx
.Pattern = "(d{1,3}.){3}d{1,3}"
.Global = False
End With
Set fil = FSO.GetFile(TempFil)
' Access temporary file
Set ts = fil.OpenAsTextStream(1)
txtAll = ts.ReadAll
Set RegM = RegEx.Execute(txtAll)
' Return IP address to Activesheet cell A1 by parsing text
ActiveSheet.Range("cx1").Value = RegM(0)
ActiveSheet.Range("cx1").EntireColumn.AutoFit
ts.Close
' Remove temp file
Kill TempFil
Set ts = Nothing
Set wsh = Nothing
Set fil = Nothing
Set FSO = Nothing
Set RegM = Nothing
Set RegEx = Nothing
Dim lastRow As Object
Set lastRow = Plan41.Range("bz:bz").End(xlUp)
lastRow.Offset(0, 0).Value = 2
Sheets("tela de boas vindas").Select
UserForm7.Show
End Sub
Postado : 08/08/2014 1:29 pm