本文整理汇总了Python中win32com.client.Dispatch.DisplayAlerts方法的典型用法代码示例。如果您正苦于以下问题:Python Dispatch.DisplayAlerts方法的具体用法?Python Dispatch.DisplayAlerts怎么用?Python Dispatch.DisplayAlerts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类win32com.client.Dispatch
的用法示例。
在下文中一共展示了Dispatch.DisplayAlerts方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: save2xlsx
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import DisplayAlerts [as 别名]
def save2xlsx(fname, output_dump=None):
"""
Do a simple : create empty xlsx, paste python list as content, save as given
fname, close and quit MS Excel
"""
from win32com.client import Dispatch
if output_dump is None:
output_dump = []
xlapp = Dispatch("excel.application")
xlapp.DisplayAlerts = False
xlapp.Visible = True
xlapp.ScreenUpdating = True
# create a new spreadsheet
xlbook = xlapp.Workbooks.Add()
# use the first worksheet
sht1 = xlbook.Sheets("Sheet1")
# inserts all the accepted claims
address = list2exceladdress(output_dump)
pprint(address)
ur1 = sht1.Range(address)
ur1.Value = output_dump
xlbook.SaveAs(fname) # save the spreadsheet
xlbook.Close() # close the workbook
xlapp.DisplayAlerts = True
xlapp.Quit() # quit Excel
示例2: convert
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import DisplayAlerts [as 别名]
def convert(self):
try:
# initialize COM for multi-threading, ignoring any errors
# when someone else has already initialized differently.
pythoncom.CoInitializeEx(pythoncom.COINIT_MULTITHREADED)
except pythoncom.com_error:
pass
word = Dispatch("Word.Application")
word.Visible = 0
word.DisplayAlerts = 0
doc = word.Documents.Open(self.fullname)
# Let's set up some html saving options for this document
doc.WebOptions.RelyOnCSS = 1
doc.WebOptions.OptimizeForBrowser = 1
doc.WebOptions.BrowserLevel = 0 # constants.wdBrowserLevelV4
doc.WebOptions.OrganizeInFolder = 0
doc.WebOptions.UseLongFileNames = 1
doc.WebOptions.RelyOnVML = 0
doc.WebOptions.AllowPNG = 1
# And then save the document into HTML
doc.SaveAs(FileName="%s.htm" % (self.fullname),
FileFormat=8) # constants.wdFormatHTML)
# TODO -- Extract Metadata (author, title, keywords) so we
# can populate the dublin core
# Converter will need to be extended to return a dict of
# possible MD fields
doc.Close()
示例3: docFilter
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import DisplayAlerts [as 别名]
def docFilter(fileList):
'''
转换word为txt,提取信息后清除txt.
'''
error_file = []
for f in fileList:
# fileName = f.split('\\')[-1].split('.')[-2].decode('gbk')
# filePath = ''.join(f.split('\\')[:-1]).decode('gbk')
f = os.path.realpath(f)
fileName = f.split('\\')[-1].split('.')[0]
print fileName.decode('gbk') + ' start ..'
print '-------------------------------------'
word = Dispatch("Word.Application")
# 后台静默运行
word.Visible = 0
word.DisplayAlerts = 0
try:
doc = word.Documents.Open(f,0,ReadOnly = 1)
saveFileTxt = re.sub('.doc','.txt',f).decode('gbk')
#保存为 txt 格式
doc.SaveAs(u'%s' % saveFileTxt ,7)
content = open(saveFileTxt,'r').read()
#开始过滤
pattern_result = Filter(content)
except Exception, E:
print E
error_file.append(f)
continue
finally:
示例4: convert
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import DisplayAlerts [as 别名]
def convert(path, tempPath):
if not path or not os.path.exists(path) or not os.path.isfile(path):
raise Exception('Path Not Found Or Path Invalid')
app = Dispatch('Word.Application')
app.Visible = 0
app.DisplayAlerts = 0
app.Documents.Open(FileName=path)
app.ActiveDocument.SaveAs(FileName=tempPath, FileFormat=2)
app.Quit()
示例5: RunExcelMacro
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import DisplayAlerts [as 别名]
def RunExcelMacro():
myExcel = Dispatch('Excel.Application')
myExcel.Visible = 1
myExcel.Workbooks.Add('C:\Users\zhli14\Desktop\Daily Report\MTD files\loaded.xlsm')
myExcel.Run('Prepare_MTD')
myExcel.Run('Find_New_Lines_and_Check_Campaigns')
myExcel.DisplayAlerts = 1
myExcel.Save()
myExcel.Quit()
示例6: RunExcelMacro
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import DisplayAlerts [as 别名]
def RunExcelMacro(FN, MacroName):
xl = Dispatch('Excel.Application')
xl.Visible = 1
xl.DisplayAlerts = 0
xl.Workbooks.Open(FN)
xl.ActiveWorkbook.Sheets("IEUBK_in").Activate
xl.ActiveWorkbook.Sheets("IEUBK_in").Range("F10:F93").Value = 100 #soil
xl.ActiveWorkbook.Sheets("IEUBK_in").Range("G10:G93").Value = 50 #dust
xl.ActiveWorkbook.Sheets("IEUBK_in").Range("I10:I93").Value = 5 #dust
#xl.Run('RunShell')
#xl.ActiveWorkbook.SaveAs(Filename="C:\Tools\Book2.xlsm")
xl.Quit()
示例7: RefreshXlsx
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import DisplayAlerts [as 别名]
def RefreshXlsx(fname):
from os.path import exists
from win32com.client import Dispatch
if not exists(fname):
return ()
xlapp = Dispatch('Excel.Application')
# xlapp = EnsureDispatch('Excel.Application')
xlapp.DisplayAlerts = False
xlapp.Visible = True
xlapp.ScreenUpdating = True
xlBook = xlapp.Workbooks.Open(fname)
xlBook.RefreshAll()
xlBook.Save()
xlBook.Close()
xlapp.Quit()
del xlapp
示例8:
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import DisplayAlerts [as 别名]
xlSht = xlWb.Worksheets (1)
instr_type = xlSht.Cells(11,3).Value
if (instr_type == 'L2130-i'):
xlSht1 = xlWb.Worksheets (2)
xlSht1.Cells(18,4).Value=float(E17_dep)
xlSht1.Cells(25,4).Value=float(d1716_dep)
else:
xlSht1 = xlWb.Worksheets (2)
xlSht1.Cells(18,4).Value=float(E17_dep)
xlSht1.Cells(25,4).Value=float(d1716_dep)
#
# Disable the message prompt for saving the files
#
xlApp.DisplayAlerts=False
#
# Save the COC and Close the file
#
xlWb.SaveAs(file_name)
xlApp.Workbooks.Close()
#
# Set the defualt behaviour and quit
#
xlApp.DisplayAlerts=True
xlApp.Quit()
print "\nAnalysis Complete....."
raw_input("\nPress Enter to exit")
示例9: print
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import DisplayAlerts [as 别名]
book = xl.Workbooks.Open(excelPath)
logging.debug("Excel book {}".format(book))
raise
for sheet in xl.book.Worksheets:
print("Processing", sheet.name)
for worksheet in xl.book.Worksheets:
if worksheet.name == sheet.name:
print("Skipping:",worksheet.name)
this_sheet = worksheet
print(this_sheet)
if 0:
with util_xl.ExtendedExcelBookAPI(full_path) as xl:
print(xl.book)
xl.DisplayAlerts = False
for sheet in xl.book.Worksheets:
print("Processing", sheet.name)
new_full_path = os.path.join(path_dir,'{}_split.xls'.format(sheet.name))
#raise
#new_workbook = copy.copy(xl.book)
new_xl = xl.clone(new_full_path)
#new_workbook.DisplayAlerts = False
#raise
#raise
print("New excel API:",new_xl)
#for worksheet in xl.book.Worksheets:
print("New excel API, book:",new_xl.book)
for worksheet in new_xl.book.Worksheets:
if worksheet.name == sheet.name:
print("Skipping:",worksheet.name)
示例10: exportMaterial
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import DisplayAlerts [as 别名]
def exportMaterial(hOwnExcelInterface,hPathExcelUtilities,hPathExcelExports,hMaterialName,hHSA,myMaterialData,hConsiderTemperatures,hConsiderStrainRates):
starttime = datetime.now()
print '... exporting material data ...'
# Checking Excel-Interface
if hOwnExcelInterface == 'Use own Excel-Interface (recommended)':
print '... ... using own Excel-Interface'
import win32com.client
from win32com.client import constants as c
from win32com.client import Dispatch
import os
try:
currDir = os.path.dirname(os.path.abspath(__file__))
myExcelExportFile = "%s/%s/%s-%s.xlsx"%(currDir,hPathExcelExports,hMaterialName,hHSA)
# if os.path.exists(myExcelExportFile):
# print '... ... ... finding existing xls-file ...'
# f = file(myExcelExportFile, "r+")
# else:
# print '... ... ... file not found ...'
# print '... ... ... creating xls-file ...'
# f = file(myExcelExportFile, "w")
#print '... ... accessing xls-file.'
print '... ... connecting to Excel...'
xlApp = Dispatch('Excel.Application')
#xlApp.Workbooks.Open(myExcelExportFile)
xlApp.Workbooks.Add()
row = 1
activeSheet = xlApp.ActiveSheet
print '... ... exporting data ...'
activeSheet.Cells(row,1).Value = 'Strain_phi'
activeSheet.Cells(row,2).Value = 'Stress_sigma'
activeSheet.Cells(row,3).Value = 'Strainrate'
activeSheet.Cells(row,4).Value = 'Temperature'
for index, data in enumerate(myMaterialData):
#print data
row += 1
activeSheet.Cells(row,1).Value = data[0]
activeSheet.Cells(row,2).Value = data[1]
if (hConsiderStrainRates == True) and (hConsiderTemperatures != True):
activeSheet.Cells(row,3).Value = data[2]
if (hConsiderStrainRates != True) and (hConsiderTemperatures == True):
activeSheet.Cells(row,4).Value = data[2]
if (hConsiderStrainRates == True) and (hConsiderTemperatures == True):
activeSheet.Cells(row,3).Value = data[2]
activeSheet.Cells(row,4).Value = data[3]
except:
xlApp.DisplayAlerts = False
xlApp.Quit()
xlApp = None
del xlApp
print '****ERROR**** connecting with Excel or Excel-file'
return
print '... ... saving and closing Excel-file ...'
try:
xlApp.ActiveWorkbook.SaveAs(myExcelExportFile)
xlApp.ActiveWorkbook.Close(SaveChanges=True)
print "... Excel-file sucessfully created: %s" %(myExcelExportFile)
except:
print '****ERROR**** saving Excel-file'
print ' '
print '... closing connection to Excel ...'
xlApp.Quit()
del activeSheet
xlApp = None
del xlApp
print '... done.'
print ' '
else:
print ' ... ... using own Abaqus Excel-Utilities'
import sys
#print hPathExcelUtilities
#print 'C:\\Program Files\\abaqus\\v6.12\\6.12-1\\code\\python\\lib\\abaqus_plugins\\excelUtilities'
sys.path.insert(3,hPathExcelUtilities)
import abq_ExcelUtilities.excelUtilities
try:
plotNames = session.xyDataObjects
for key in plotNames.keys():
#print "key: %s , value: %s" % (key, plotNames[key])
abq_ExcelUtilities.excelUtilities.XYtoExcel(xyDataNames="%s"%(key),trueName='From Current XY Plot')
print " ... ... ... exported %s" % (key)
except :
print '****ERROR**** Either path to Abaqus Excel-Utilities is wrong or no XY-Data found. I this case, ensure that Plot-Material-Option is activated.'
exit()
return
print '... ... done.'
# Print computation time for this operation
elapsedTime(starttime)
示例11: Dispatch
# 需要导入模块: from win32com.client import Dispatch [as 别名]
# 或者: from win32com.client.Dispatch import DisplayAlerts [as 别名]
myExcel = Dispatch('Excel.Application')
myExcel.Workbooks.Close()
# no screen flashes -- redundancy, turned off in VBA code
myExcel.Visible = 0
print str(datetime.datetime.now().strftime('%Y%m%d %H:%M:%S')) + ':\topening workbook'
myExcel.Workbooks.Open(file)
# must wrap file name in single quotes if file name contains spaces
print str(datetime.datetime.now().strftime('%Y%m%d %H:%M:%S')) + ':\trunning macro'
myExcel.Run("'" + file + "'" +'!close_and_save')
# no pop up prompts when deleting tabs or saving as. Redundancy, they are turned off in the VBA code. If doing in VBA, just remember to switch it back to 'true' in vba as last line of macro.
myExcel.DisplayAlerts = 0
myExcel.Workbooks.Close()
"""
Program Report SQL Run and File Creation Module End
"""
"""
Text Subscription Module Begin
"""
#RETRIEVE SUBSCRIBER GOOGLE DOC
#set retrieval credentials
username = "google_user"